PDA

View Full Version : can you use code to detect when a variable changes?



lac
September 12th, 2003, 09:10 PM
Well basically what I want to do is have my code figure out that a variable has changed value and then call a function to store that value in my class.

I have a component with a text box in it that displays a value gotten from either typing in the box or moving a slider. I then need the last value (where they stop sliding or typing) to be stored in my class.

Is there any other way than trying to use the onChange of the text box?

Thanks in advance

Liz

grandsp5
September 12th, 2003, 09:29 PM
onClipEvent(enterFrame){
var new = variable;
if(new == old){
old = new;
}
}

Voetsjoeba
September 13th, 2003, 01:53 AM
Grandsp5 - You are checking if they are equal, and if they are, set them equal. Doesn't make much sense, does it ?

Liz - There will always be another "last value". Say I don't slide the slider for a while, and then I slide it again, then what's the last variable ?

grandsp5
September 13th, 2003, 03:40 AM
oops. sorry i forgot a statement.

onClipEvent(enterFrame){
var newOne= variable;
if(newOne == old){
old = newOne;
}
else{
//variable has changed
}
}


my bad :trout:

grandsp5
September 14th, 2003, 02:40 AM
my question is wouldnt you know when it changes considering something has to change it? Couldn't you just put whatever code you need after that event?