When I'm in the flash debugger, and I have some callbacks saved, I can see that the functions have a property named savedThis
that is very usefull to know where that callback came from.
I'm trying to access that property from code, but for some reason I can't.
callback.savedThis
throws an Error because it can't find the property, probable because it's private.
So I tried to add a method to the Function class that would give me access to it:
Function.prototype.getSavedThis = function()
{
return this.savedThis
}
But it gives me the same error about not finding the property, even though I can see it in the debugger. Is there a way to access it?
Note: I'm not planing on using this in production code, I'm making some classes to help me with debugging by automating some data gathering, and it would be incredible useful to get this information without having to add code to every callback saved informing of the this object.
-
You can get a reference to a calling function by using the 'arguments.callee' property.
For example:
bar( arguments.callee ); public function bar( caller:Function ) : void { trace( caller ); }
Turambar : But I have no way of linking the calling function to the object that owns it
0 comments:
Post a Comment