Beginner's trouble with If-Else
I am just learning AS. I am trying to make a username and password box that will return a welcome message if the two text fields are entered correctly and a “Sorry Charlie” message if they are not.
I am using an If-Else statement. If I have the Else part commented out, I am able to enter text into the two text fields and get a welcome message. With the else statement though, I am not able to finish entering text in the second text field before the “Sorry Charlie” message appears.
Please, how can I make the password text field wait until all the info has been entered and listen for the Enter key?
Thank you!
passwordBx.addEventListener(KeyboardEvent.KEY_DOWN, greeting, false, 0, true);
//var anyName:String; Want to be able to enter any name later
function greeting(evt:KeyboardEvent):void {
if(userNameBx.text = = "Marta" && passwordBx.text = = "Chicken" && evt.keyCode = = Keyboard.ENTER) {
evt.keyCode == Keyboard.ENTER
welcomeBx.text = "Welcome " + userNameBx.text;
return;
//}else{
//welcomeBx.text = "Sorry Charlie!";
}
}