views:

17

answers:

1

Hi,
How do I get this to work more like a login, where the textfield accepts the numbers and entered? Thanks for the help,

var login:int = 0;
//KEYPAD LISTENERS
num1.addEventListener(MouseEvent.CLICK, num1b);
num2.addEventListener(MouseEvent.CLICK, num2b);
//...
//KEYPAD FUNCTION
function num1b(e:MouseEvent):void{
login = 1;
trace(login);
tx.text = String(login);
}
function num2b(e:MouseEvent):void{
login = 2;
trace(login);
tx.text = String(login);
}
//CAN ENTER SITE
addEventListener(Event.ENTER_FRAME, entry);
function entry(evt:Event):void{
if(login == 528){
//gotoAndPlay();        
}
}

I'm making a keypad to login to a Flash site and see a portfolio. The values don't enter in the dynamic textfield without incrementing or overwriting each other.

Tried this

//numb1b
tx.text = tx.text + "1"; 
//numb2b
tx.text = tx.text + "2"; 
+1  A: 

Instead of using numbers, use Strings/characters:

var login:String = "";
//KEYPAD LISTENERS
num1.addEventListener(MouseEvent.CLICK, num1b);
num2.addEventListener(MouseEvent.CLICK, num2b);
//...
//KEYPAD FUNCTION
function num1b(e:MouseEvent):void{
login = login + "1";
trace(login);
tx.text = login;
}
function num2b(e:MouseEvent):void{
login = login + "2";
trace(login);
tx.text = login;
}
//CAN ENTER SITE
addEventListener(Event.ENTER_FRAME, entry);
function entry(evt:Event):void{
if(login == "528"){
//gotoAndPlay();        
}
}
Wade Mueller
Doh, you edited your question while I was responding. :)
Wade Mueller
@Wade Thanks. I found that 'tx.appendText("1");' works too.
pixelGreaser
textField.appendText( "string" ); is MUCH faster than textField.text = textField.text + "string"; or even textField.text += "string";
jolyonruss