I'm used to a more event driven environment but the copy I'm working at now dose everything as function call backs. When I asked about this one of the devs said it was because callbacks are faster because of bubbling, but the bubbling property could always be set to false...
So I'm having the problem of trying to figure out which callback function is being referenced.
For example:
public class A {
public function A(){}
public function func_1():Number{ return 1; }
public function func_2():Number{ return 2; }
public function doSomething:Function{
if( Math.random > 0.5 ) return func_1; else return func_2;
}
}
Then I might run the code in class B:
public class B{
public var a:A = new A();
private var action:Function;
public function B(){ action = a.doSomenthing(); }
}
So when I put a break point inside B I get action = Function (@34567) which is really completely useless... I realize I could put a break point in both func_1 and func_2 but I'm just using this as a general example there are function callbacks sprinkled through out the code... is there a way to get the name of a function by memory address? Thanks
I guess I see what you are saying about the stack trace. But you have to physically step over the function in the code. In this example below I'd have to put a break point on callback(); and step over it to see the stack trace update. The issue is I want to know the callbacks before they are called. Sometimes they are called in other places. There is no other way to get the callback?
public var callbacks:Array = [];
public function loadURL( url:String, callback:Function ){
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
callbacks.push( callback );
var request:URLRequest = new URLRequest(url);
loader.load(request);
}
public function completeHandler( event:Event ):void
{
for( var i:int = 0; i < callbacks.length; i ++ ){
var callback:Function = callbacks[i];
callback();
}
}