I want to watch a property of an object to see when it changes, like so:
[AS]
var myObject:Object = new Object();
myObject.xDirection = -1;
function objectWatcher(prop, oldVal, newVal) {
trace ("xDirection is being changed from " + oldVal + " to " + newVal);
return newVal;
}
myObject.watch(“xDirection”, objectWatcher);
myObject.xDirection = 22;
[/AS]
This works as expected.
But if the value of the property being watched, is changed within a function, is there a way to tell which function that was?
EG:
[AS]
var myObject:Object = new Object();
myObject.xDirection = -1;
function objectWatcher(prop, oldVal, newVal) {
trace ("xDirection is being changed from " + oldVal + " to " + newVal);
//I want to be able to output something like this:
trace("It was changed by " + NAME_OF_CALLING_FUNCTION);
return newVal;
}
function changeTheValue():Void {
myObject.xDirection = 22;
}
myObject.watch(“xDirection”, objectWatcher);
changeTheValue();
[/AS]
Any help would be appreciated. Thanks.