It’s been a while since I mentioned the all important discipline of tracing in ActionScript to get an inside look at what your application is doing. Getting feedback from your program at important points can mean the difference between hours of debugging and a quick analysis of the issue at hand. Previously there was the FDTracer plugin, but this is no longer needed. There are actually three much better ways that suite different situations.
Outputting information to a debug log can help you tremendously when struggling with annoying problems. Depending on the situation, there are a few options you can try out.
You might want to follow along in this FlashDevelop project.
Plain old trace()
ActionScript already has a trace statement. It’s probably not so well known because you need to have the right Flash player for this to work. You either need to use the standalone player or the debug player. If you’ve installed FlashDevelop correctly, you should be fine. Keep in mind that an automatic Flash upgrade might have replaced your manually installed debug vesion.
FlashDevelop’s FlashConnect
If you’re developing with FlashDevelop, you can also use the build-in org.flashdevelop.utils.FlashConnect. The FlashConnect.trace directive connects to your running FlashDevelop instance and sends trace information directly to the console. If you have a Flash debug player installed this looks exactly like the previous statement.
It is useful if you don’t have a debug player, because it will work with any Flash player.
Firebug tracing
Both of the above options won’t be very handy when you are developing for the web. You can try to find your Flash log file, but wouldn’t is be much easier to see trace information directly in our favorite web debugging tool, Firebug?
It’s actually possible and fairly easy to get trace output to Firebug:
ExternalInterface.call("console.log", "tracing in firebug");
That’s all there is to it. Keep in mind that, due to security restrictions, this will only work when you deploy the Flash file to a remote server and use swfobject.js to start the program. FlashDevelop creates this configuration by default for you.