I recently took on some contract development for another AS3 project and because I wasn’t particularly happy with the way I debugged my flash work in the past I decided to come up with a better solution. Not many traditional flash coders realize that they can view the output from their trace statements on a live compiled SWF. The way you do that is fairly straightforward.
- Download the Flash Player Debugger version.
- Create an alias in your profile to tail the flashlog.
Creating an Alias Command
Once you install the debug player, any movie you open in your browser will output it’s trace commands to a flashlog.txt file. This is normally located in the Library directory for your user. So we’re going to make an alias to open it quickly in terminal. If you’re not familiar with alias commands think of them as shortcuts in terminal.
Let’s get straight to the meat of it. First we have to find our flashlog. By default the flashlog is stored here:
/Users/[your system username]/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt’
If for whatever reason you aren’t getting a flashlog you may need to look into taking some simple modifications to your mm.cfg file.’ Otherwise you should be ready to make your alias command.
We want to put our alias command in our shell profile so that the shortcut will be available for us automatically when we open up terminal. To do this launch a new terminal window and type:nano ~/.bash_profile
Nano works like a regular text editor, so simply paste the alias command below any existing statements in the document, be sure to replace your system username with your actual user name:
alias fl='tail -F /Users/[your system username]/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt’
Now that you’ve done that hit ctrl-o to save the changes you’ve just made to the file and ctrl-x to exit nano. Now close the terminal window and open a new terminal. Type ‘fl’ and press enter. You can now see the live output as any instance of the player writes output to the flashlog. If you want to stop viewing output just hit ctrl-c while you’re in the terminal window to close the stream.
Donald Bellenger Says:
11:03 amOct 15Why not use flash’s remote debugging tools? Remote debugging from the flash IDE isn’t as smooth as it could be, but I think with the inclusion of breakpoints and real-time object/property monitoring it’s going to be much more powerful than this approach. I feel like Adobe doesn’t shine enough light on the remote debugger, as many people seem unaware of it. I only recently discovered it, I couldn’t believe how I ever survived without it.
Jim Jeffers Says:
10:41 amOct 19Thanks Donald - I will definitely have to give the debugger more thought. But this method still works very well for myself. It also allows me to easily diagnose something that has gone haywire on a live production site.