a great textfield listener.
i have found a great way to do textfield listeners..
first the code..
——————————————————————————–
stop();
//define an onChanged handler for when text changes in the input text field
f15input_txt.onChanged = function(txt) {
trace(txt._name+” has changed”);
};
//construct the listener object
myListenerObject = new Object();
myListenerObject.onChanged = function(txt) {
trace(txt._name+” changed and has notified myListenerObject”);
if (f15input_txt.text == “47″) {
trace(”47 input”);
f15output_txt.text = “Correct Answer”;
loadMovie(”media/loader.swf”, 3);
}else{
unloadMovieNum(3);
f15output_txt.text = “Input Correct Answer.”;
}
};
//call the TextField.addListener method to register the object
f15input_txt.addListener(myListenerObject);
——————————————————————————
the steps..
1. define an onChanged handler for when text changes in the input text field
e.g. myTextField_txt.onChanged = function(txt) {}
2. construct the listener object
e.g.
myListenerObject = new Object();
myListenerObject.onChanged = function(txt) {}
3. call the TextField.addListener method to register the object
e.g.
myTextField_txt.addListener(myListenerObject);
it is a great way to monitor the textfield activity and sure beats the lame way i was doing it.. doh to me!
