toddclare
04-18-2005, 07:26 PM
I've got 2 TextInput instances on stage. When the user is editing #1 and either (a) hits enter or (b) takes the focus away from #1, I want to make sure they entered something. I'm trying to solve (b) first and ran into a infinite loop...
Here is what I tried:
stop();
text1_ti.text = "Start 1";
text2_ti.text = "Start 2";
var obj:Object = new Object();
obj.focusOut = function() {
trace("Focus Out");
if (text1_ti.text.length == 0) {
trace ("Zero Length Text 1");
Selection.setFocus("text1_ti");
}
trace("Focus is now: " + text1_ti.getFocus());
}
text1_ti.addEventListener("focusOut", obj);
When they erase the default text and click on #2, it recognizes the problem, but gets into an infinite loop (it hits 256 executions and stops.
is there another solution? Am I not using this correctly?
I attached the FLA, but every line of code is shown above. Thanks!
Here is what I tried:
stop();
text1_ti.text = "Start 1";
text2_ti.text = "Start 2";
var obj:Object = new Object();
obj.focusOut = function() {
trace("Focus Out");
if (text1_ti.text.length == 0) {
trace ("Zero Length Text 1");
Selection.setFocus("text1_ti");
}
trace("Focus is now: " + text1_ti.getFocus());
}
text1_ti.addEventListener("focusOut", obj);
When they erase the default text and click on #2, it recognizes the problem, but gets into an infinite loop (it hits 256 executions and stops.
is there another solution? Am I not using this correctly?
I attached the FLA, but every line of code is shown above. Thanks!