How many times have you built something in Flash, tested it a million times or more, have it work great, and then fail as soon as you put it online, or outside the Flash IDE? You then go back to your local version, test some more, and begin throwing
trace("something here"); and
trace("whyIsntThisWorking"); everywhere. It all works great, and then you put it online again, and it doesn't work. Personally, this seems to happen to me quite often on certain projects. I've often wished that there was some way to trace out what's going on in my .swf files online, so I can figure out what's happening.
Well, hallelujah, brothers and sisters, you can now do this, and I will testify unto you that it is almost a miracle. I've been trying to debug a project at work for about a week now, that used to work fine online, and now it doesn't. But using the technique below, I was able to trace out some info from the swf online, and figure out exactly where my problem was. This will also log errors such as undefined functions and variables for you as well, so this is a valuable tool. The cool thing about this is that it logs the info from any swf that you visit online. Just for fun visit a few Flash sites, and then open up the flashLog.txt file we'll create, and you'll see anything that they may have been tracing.
Disclaimer: I did not discover this on my own, so I can't take complete credit for it. I just thought it was an amazing debug tool, so I'm trying to spread the word. One day in my random travels around the web, I came across the following blog - g.wygonik's flash experiments They claim it's a Windows only tool, but I started playing around, and I've got it working just fine in OSX. Quick warning to Safari users, the site doesn't display properly, so use FireFox instead.
The secret comes from Macromedia Flex and it's debugging abilities. For this to work, you'll need to have the Flash Debug Player installed. This means that you'll want to uninstall your current Flash Player, and install the debug player instead. You can find an uninstaller here - http://www.macromedia.com/shockwave/download/alternates/. You'll be able to find the Debug Player in your Flash install folder. For OSX users, you'll find it in /Applications/Macromedia Flash MX 2004/Players/Debug/Install Flash Player 7 OSX.app. Windows users, it'll be in a similar location. Refer to the article above for Windows instructions.
Once you have uninstalled the Flash Player, and installed the Debug Player, (you'll need to restart your browser, so bookmark this page) you can verify that you have the Debug Player installed by right-clicking (control-click - just get a real mouse already Mac users) on a swf. You should have the "debug" option in the context menu, like the example below. Once that's working, onto the next step.
Create a textfile called "mm.cfg". Inside the file, there are a few options for you. The most important options for this to work are below:
ErrorReportingEnable=1 TraceOutputFileEnable=1 TraceOutputFileName=MacHD:Users:username:Desktop:flashLog.txt MaxWarnings=50
Swapping "MacHD" with your computer name, and "username" with yours. You can put this wherever you want, just make sure you use the colons ":" and not slashes if you're using OSX. Windows users, same thing, put it where you want it, but you'll use "/" of course.
ErrorReportingEnable=1 does just that - it enables error reporting. Then,
TraceOutputFileEnable=1 enables the output file. You may be getting the idea now. The
TraceOutputFileName is the path to where you want this file to be exported. I like to keep mine on my desktop. There are very few things that make it to my desktop, and this file is one of them, it's that cool. The
MaxWarnings is the maximum amount of warnings you want reported. This doesn't limit your
trace() statements, just the ActionScript warnings about undefined variables or methods. By default, this is set to 100, so you can leave this line out if you like. Or, you can set it to 0, and it there will be no limit placed. You can find more info about the options you have for this file in the Macromedia LiveDocs for Flex
Now, save this file, and place it in the following location:
- OSX users - MacHD/Library/Application Support/Macromedia/mm.cfg
- Windows - C:\Documents and Settings\username - follow the instructions in the link to g.wygonik above.
You don't need to create flashLog.txt, it will be created for you.
Now for the fun part. Open Flash, and create a quick movie with the following lines:
trace("hello world"); trace(bob); _root.callFunction(); var something = 5; trace("something: " + someThing);
Publish the swf, and open it in your browser. Or, click the button below.
Now go to the location where you told the flashLog.txt file to be written to. Open this up, and you should see something similar to the following output:
Look at all the cool stuff you get - a warning that a function you're calling doesn't exist, variables being traced out, and a notice that you probably typed a variable wrong. Isn't this thing great? If you decide to make changes to your mm.cfg file, you'll need to restart your browser for those changes to take effect.
You don't need to worry about clearing the flashLog.txt file, it will be cleared with each new swf file that you view. If you have problems setting this up, e-mail me, and I'll try to respond as soon as I can.
|» Level Basic|
Rating: 8 Votes: 10
|Josh Buhler is a Flash designer based in Salt Lake City, UT.|
|Download the files used in this tutorial.|
|Download (0 kb)|
|More help? Search our boards for quick answers!|