package { import flash.display.Sprite; import flash.text.TextField; /** * @author tvandeneijnden */ public class GetFunctionNames extends Sprite { private static var _tf : TextField; public function GetFunctionNames() { first(); } public function first() : void { log('--- inside: first ---'); log('current fuction: ' + currentFunctionName()); log('callee fuction: ' + calleeFunctionName()); second(); } public function second() : void { log('--- inside: second ---'); log('current fuction: ' + currentFunctionName()); log('callee fuction: ' + calleeFunctionName()); } public static function currentFunctionName() : String { var s : String = new Error().getStackTrace(); s = s.substring(s.indexOf("at") + 2); var i : int = s.indexOf("at") + 3; var j : int = s.indexOf("()", i); return s.substring(i, j); } public static function calleeFunctionName() : String { var s : String = new Error().getStackTrace(); s = s.substring(s.indexOf("at") + 2); s = s.substring(s.indexOf("at") + 2); var i : int = s.indexOf("at") + 3; var j : int = s.indexOf("()", i); return s.substring(i, j); } public function log(message : String) : void { if(!_tf) { _tf = new TextField(); _tf.width = 300; _tf.height = 200; _tf.multiline = true; addChild(_tf); } _tf.appendText(message + "\n"); } } } calleeFunctionName() & currentFunctionName()