Detect when a variable changes in flash
Here is a nifty little script to keep track of variables. Basically you declare a variable, create a callback to be fired when the variable changes, and then you "watch" it.
// Declare your variable (can be any kind)
var myVar:Number = 0;
// Here's your callback that will be fired every time you change your var
myVarChangeCallBack = function (varName, oldval, newval):String {
trace ('Variable "' + varName + '" has changed from ' + oldval + ' to ' + newval);
return newval;
};
// Watch your var for changes
watch("myVar", myVarChangeCallBack);
// Some code to try this out
_root.onMouseDown = function () {
myVar++;
}Leave a comment