Is there a way to check if an integer will be higher or lower in AS3
I am trying to make a script that listens to a variable (int or Number) and then performs certain functions, whether the variable is above or below. So, for example, if the number gets higher, it performs one function. If it gets lower, it starts another one.
Is this possible in AS3? Any ideas?
+2
a source to share
3 answers
Use a private variable with an installer. In the setter, compare the previous value with the current value:
private var _num:Number = 0;
public function set num(value:Number) : void {
if (value < _num) {
//do something if it lower
} else if (value > _num) {
//do something if it higher
} else {
// do something if it equal
}
_num = value;
}
+7
a source to share