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:
http://blogs.adobe.com/aharui/2007/10/debugging_tricks.html
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…