given the following
function A(b:Function) { }
If function A(), can we determine the name of the function being passed in as parameter 'b' ? Does the answer differ for AS2 and AS3 ?
I use the following:
private function getFunctionName(e:Error):String {
var stackTrace:String = e.getStackTrace(); // entire stack trace
var startIndex:int = stackTrace.indexOf("at ");// start of first line
var endIndex:int = stackTrace.indexOf("()"); // end of function name
return stackTrace.substring(startIndex + 3, endIndex);
}
Usage:
private function on_applicationComplete(event:FlexEvent):void {
trace(getFunctionName(new Error());
}
Output: FlexAppName/on_applicationComplete()
More information about the technique can be found at Alex's site: