TextField setFocus

I have just learnt how to put the focus onto an input textfield.
First create an input textfield and give it the instance name of “input_txt”

then all you need is this line of code that sets the focus or puts the cursor into that textbox ready for the user to input some text..


Selection.setFocus("input_txt");

Another dodgy trick i have been using to test the input of a text box is to put an if statement inside an onEnterFrame loop..
its a bit of a hack and probably shouldn’t be done. but it is quick and dirty and it works in a fashion.


// loop to test text input
this.onEnterFrame = function() {
if (input_txt.text == "Steve is a genius") {
output_txt.text = "That is correct";
} else {
output_txt.text = "Input CORRECT answer above";
}
};

If you have any questions, Please go to the forums and ask away

Leave a Reply

You must be logged in to post a comment.