Groups | Blog | Home
all groups > flash actionscript > february 2004 >

flash actionscript : Setting variables using onChanged


mfkilner
2/21/2004 10:06:46 PM
I have two variables that need seeting when the contents of a text field
change, I have been trying to use the onChanged event to trigger the setting of
these variables but cannot make this work correctly. The code I have got so far
is below.

Can anyone please tell me how to make this work?

Thanks

txt.onChanged = function() {
set(mark, 1);
set(answer, 1);
};
NSurveyor
2/21/2004 10:27:03 PM
Create a new movie clip
ON Frame 1 Create an input text box. Set the parameters (properties panel) to:

Variable: text
Maximum Char: 3
Character Options: Only -> Numerals (0-9)
Then use the following script for the current frame:

if (text == 100) {
mark = 1;
answer = 1;
// answer=1 is sort of pointless, since no matter what the outcome, it still
is 1.
// I would just say answer = 1 outside the if, but that doesn't matter
} else if (text <> 100) {
mark = 0;
answer = 1;
}
finally create a new frame at Frame 2 in the movie clip
mfkilner
2/21/2004 11:07:23 PM
The reason for using onChanged was to avoid having the variable answer always
set to 1. It needs to be set to 0 until something is entered in the text box.
The only way I can think of avoiding answer always being set to 1 is the
onChanged handler but cannot make it work.
Unless you can suggest an alternate way of checking if a change has occured in
the text box??

AddThis Social Bookmark Button