AS3 Debugging Help – My New Friend – getStackTrace()

This week, for my sins, I have been integrating a Flip Book component into a site I have built using the awesome Gaia Framework. Together, these two code libraries constitute tens of thousands of lines of code and I was getting some run-time errors that I found incredibly difficult to solve. The error text being thrown in the output window revealed next to nothing about where the errors were occurring. Much googling later, I came across a debugging trick that has, until now, passed me by. Basically, you can throw a stack trace in the Debug player at runtime to see exactly where code at that point is originating/firing from. Doing this helped me to instantly locate the source of my troubles. Here is the code:-

//creating but not throwing the error
var er:Error =new Error("BREAK");
// see where issue is happening, but continue running
trace("getStackTrace(): "+er.getStackTrace());

I found this useful trick here – http://troyworks.com/blog/2010/03/14/debug-actionscript-better-with-getstacktrace-trace-trick/ – much thanks to Troy Gardner.

Advertisements

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: