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.
Steven Haddox Says:
11:19 pmNov 23Great post Jim. I’ve got your post section all setup. Unfortunately I can’t get Flash Debugger to output anything to my flashlog.txt for the life of me. I’ve triple checked the directory and triple checked that my mm.cfg has the proper values (I had to create it as it didn’t exist yet). Is there anything else that’s obvious I may be missing?
Thanks and keep up the great posts.
Abdul Says:
11:44 pmDec 10I prefer it as better in the default debugger or maybe debugging the code myself after I get an error! But this isn’t too bad either!
Andy Ferra Says:
1:21 pmDec 12I like the way you’re doing it here Jim. I find the remote debugger tedious. Switching from browser to flash sucks.
+1
Jim Jeffers Says:
2:46 pmDec 12Yeah I can’t figure out how to get this working with Flash 10 yet. The flashlog doesn’t seem to be getting created anymore. I’ve heard others experiencing similar problems and have not pursued how to resolve this yet. I’m sure it’s pretty simple.
Andy Ferra Says:
7:04 pmDec 13Try creating this file and rebooting.
http://gist.github.com/35597
Andrew Says:
5:13 pmJun 14Rather than opening a new Terminal window, it’s possible to reload bash_profile using:
. ~/.bash_profileNotice the ‘.‘ at the beginning.Cheers!Jay Says:
12:06 pmJul 07With the file that Andy Ferra suggested, it worked like a charm. Thanks so much!To flesh out Andy’s instruction a bit: create a file in /Library/Application Support/Macromedia/ called mm.cfg. In that file, place the following text, then reboot:## /Library/Application Support/Macromedia/mm.cfgErrorReportingEnable=1TraceOutputFileEnable=1
Jay Says:
12:09 pmJul 07@Jayer, screwed up the formatting, sorry. maybe this will do it: ## /Library/Application Support/Macromedia/mm.cfgErrorReportingEnable=1TraceOutputFileEnable=1
Jim Jeffers Says:
12:18 pmJul 07@Jay
I’ll update my post to clarify the directions both of you posted here in the comments. Thanks for taking the time to post!