Marcos is Currently...
- @s9i これは見てないでしょ: http://snurl.com/62ibe | 18 hours ago
- About to present at fitc unconference at max | Yesterday
- @ Max, keynote is rocking. Our demo is about to go live. | 3 days ago
- Setting up our demos backstage of MAX. Whole setup and logistics for this event are quite impressive. | 5 days ago
- lovin' ajax. hacked up a dojo livesearch widget in no time. will post source soon. | 4 weeks ago
shared items in Google Reader
- John Oliver and John King’s Magic Wall | Yesterday
- Google Hosts 10 Million Historic Time-Life Photos [Google] | 2 days ago
- Emergence Project: Representing a Textual Discourse | 2 days ago
- fLux Binary Waves: Urban Visualization Installation | 2 days ago
- Let the computer figure out your cutlist | 3 days ago
recent photos on flickr
recent trips
- Returned from a trip to Seoul. | last month
- Started a trip to Seoul. | last month
- Finished a trip to Toronto. | April 2008
- Started a trip to Toronto. | April 2008
- Finished a trip to Montevideo. | March 2008
news / Debugging AS3 with firebug's console
March 25, 2007
Debugging AS3 with firebug's console
Most probably you've already heard about firebug, if you haven't, I really recommend you go give it a spin right now.
Basically, firebug let's you lift the hood in your browser and see pretty much everything that's happening in there. It lets you edit, and monitor all HTML, CSS, Javascript live in any web page - it even lets you edit those objects on the fly!
It also gives you a fantastic console that lets you expose information about what's flowing through your scripts. Adding a global variable named "console" it exposes many methods that allow you to write to the Firebug console.
The really cool thing is that from flash you can call "console" using ExternalInterface, and any object you pass will be dumped as if it was a javascript object.
try it out:
ExternalInterface.call("console.log",{foo:123,bar:"da",boo:{da:12,beh:[123,145,"dfa",{fa:[0,1,2,4,5]}]}});
and you will see the output in the image above.
To save you some time and make things cleaner, here you will find an AS3 Class that exposes the console object to any of your Actionscript/flex applications.
All methods are static so you don't need to instantiate the class.
From actionscript, all you need to do now is:
Console.log({foo:123,bar:"da",boo:{da:12,beh:[123,145,"dfa",{fa:[0,1,2,4,5]}]}});
I guess the only drawback for this is that this will bong out if you are trying to dump an object with circular references, or your object is too big. - I can't find out what's the size limit right now, but I've seen it throwing an exception when the objects I passed where too complex.
In case you need something more robust to debug your code, then I really recommend you try out FlexBuilder's debugger.
download: Console.as




















Comments
your thoughts