Jason210
asked on
Input Text problem, ActionScript 3.0
Hi
I'm making a simple password for a website, where the password is stored as a string on a timeline script.
I'm using nested conditionals (which may not be very elegant but should work) to first react when the enter key is pressed, and then look at the contents of the input text.
If the input text isn't the same as the password, then it goes to an error page, otherwise it goes to on to let you in on the website.
However, the code below is not robust enough, because if I press only the Enter key, the input text is not trapped by the conditionals. I've been trying to figure this out for ages now, and I can't.
Also, another question. I would like to be able to clear the input text area, when an error is detected. How can I do that?
I'm making a simple password for a website, where the password is stored as a string on a timeline script.
I'm using nested conditionals (which may not be very elegant but should work) to first react when the enter key is pressed, and then look at the contents of the input text.
If the input text isn't the same as the password, then it goes to an error page, otherwise it goes to on to let you in on the website.
However, the code below is not robust enough, because if I press only the Enter key, the input text is not trapped by the conditionals. I've been trying to figure this out for ages now, and I can't.
Also, another question. I would like to be able to clear the input text area, when an error is detected. How can I do that?
stop();
var nameText:String = "hello"
stage.addEventListener(KeyboardEvent.KEY_DOWN, hitKey);
function hitKey(evt:KeyboardEvent):void
{
if (evt.keyCode == Keyboard.ENTER)
{
if (inputText.text != nameText)
{
trace("error: "+inputText.text);
gotoAndStop(2);//displays an error message
}
else
{
trace("accepted: "+inputText.text);
gotoAndStop(3);//starts movie
}
}
}
trace ("Outside conditionalas: inputText.text = "+inputText.text)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks....I wondered what you were talking about at first with "prettyprint" and what not...
I try it out tomorrow.
I try it out tomorrow.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
GE