I want to see the stack trace in any function of my code, so i made somthing like this to call it and print the stack trace:
public function PrintStackTrace(
I've put together this little function:
public static function getStackTrace() : String
{
var aStackTrace : Array = new Error().getStackTrace().split("\n");
aStackTrace.shift();
aStackTrace.shift();
return "Stack trace: \n" + aStackTrace.join("\n");
}
I have this function in a custom "Debug" class I use with my apps when developing. The two shift() calls remove the first two lines: The first one is just the string "Error" and the second line refers to this function itself, so it's not useful. You can even remove the third line if you wish (it refers to the line where you place the call to the getStackTrace() function) by adding another shift() call, but I left it to serve as a starting point of the "stack trace".