I have to admit, debugging in Flash has always been a painful thing. There’s nothing more stressful when everything works fine in the IDE, but completely craps out once pushed to the site, and you’ve got to figure out the problem right freakin’ now when the most you have to go on is “um, the Flash doesn’t work.”
Enter Console Log. For those of you who don’t have Firebug, get it. Now you can trace out to the Firebug console log from your .swf.
It’s as simple as two lines of code:
First, import the package declaration:
Next, call to the log whenever you want to trace something out
ExternalInterface.call( "console.log" , "Hey! I'm tracing from Flash!");
Yes. It’s that simple. You can even add variables and other data to the trace. Just treat the argument as any other string:
ExternalInterface.call( "console.log" , "My variable is" + myVar );
This is even more useful when you can’t actually view the site. We recently had to debug an issue that was behind a client’s firewall. Rather than guessing back and forth, we were able to deliver a new .swf with a bunch of calls to the console, and solved the problem in a matter of minutes, as opposed to hours of guesswork.
Try it for yourself. You’ll appreciate how useful it is.