# Textfield == a number problem

**URL:** <https://forum.kirupa.com/t/textfield-a-number-problem/325620>\
**Category:** Uncategorized\
**Created:** [October 26, 2011, 11:18am UTC](https://forum.kirupa.com/t/textfield-a-number-problem/325620 "2011-10-26T11:18:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tenchy](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@tenchy](https://forum.kirupa.com/u/tenchy)\
**Post date:** [October 26, 2011, 11:18am UTC](https://forum.kirupa.com/t/textfield-a-number-problem/325620/1 "2011-10-26T11:18:22Z")

</div>

Arghhh, I’m going crazy over here. In AS2 it’s NOOO problem, but in AS3 it just throws errors.

What I want to do is to check if a variable is == to something they type in a textfield.

I have a textfield with the name of “pat”. The user can click it and enter a number. I want it so that if they enter 1234, the code triggers.

var lat:Number = 1234  
addEventListener(Event.ENTER\_FRAME,whatever);  
function whatever(event:Event):void {  
if (pat==lat) {  
trace(“ok”)  
Back.visible=true;  
} else {  
Back.visible=false;  
}  
}

In AS2 it didn’t care what type of stuff was entered in the textfield, it gladly compared it to any variable, but now it just complains about how it can’t compare a value with a static type blaaah:

> Scene 1, Layer ‘Layer 1’, Frame 1, Line 27 1176: Comparison between a value with static type flash.text:TextField and a possibly unrelated type Number.

And I can understand that, but how do I make it work?
