Getting the Stack Trace in a Release Flash Player
Developers have been asking for the ability to get the stack trace of errors in the release Flash Player. With the release of Flash Player 11.5 Beta this feature makes it debut. This is a beta release but I wanted to show you what it looks like and explain what this feature is about.
The code is located on my Github actionscript examples repo: https://github.com/renaun/ActionScriptExamples/tree/master/FlashPlayer11_5Beta
The main app uses a try/catch statement around a custom class method call that generates an error exception. Here is what the code looks like:
public class FlashPlayer11_5Beta extends Sprite
public function FlashPlayer11_5Beta()
var text:TextField = new TextField();
text.x = 10;
text.y = 10;
text.multiline = true;
text.width = stage.stageWidth - 20;
text.height = stage.stageHeight - 20;
var test:TestStackTrace = new TestStackTrace();
text.text = "Error: " + error.message + "\n" + error.getStackTrace();
And the customer
public class TestStackTrace
public function myTestFunction():void
bit.alpha = 0.5;
Let us take a look at the different output with this code running in the Flash Player debugger player, release player before 11.5 beta, and 11.5 beta release player (swf-version=18).
Flash Player Debugger Player – regardless what version
Error: Error #1009: Cannot access a property or method of a null object reference.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Flash Player Release Player – before 11.5 beta
Error: Error #1009
Flash Player Release Player – with 11.5 beta (swf-version=18)
Error: Error #1009
TypeError: Error #1009
You’ll notice that the new feature is missing the file classpath and line details that are present in the debug player stack trace. This makes sense because the debug symbols are not included in the release SWF. Even so, just having the class and method information of the stack trace will help a lot when tracking down those weird bugs. You know the ones that only show up with real users in the wild using your app with release versions of Flash Player.