Marcos is Currently...
- @strandjutternet thxs. Adobe ATL is def heaven for Interaction Designers. As for me, I got my startup call and couldn't let it go by! | Yesterday
- "The day Before" is probably going to be my last "weekend photo" for a while: http://flic.kr/p/7Ja9iD | 4 days ago
- @mariroom 今年中にグランドキャニョン絶対行こうよ!ギーク観光ツアーで!参加するメンバー募集頼む!ルート&企画は任せて。 | 6 days ago
- @sho_nishiyama ありがとう!がんばります! | 6 days ago
- @mariroom おっす。マリちゃんと絶対また会えるっしょ。SFいつくる? | 6 days ago
shared items in Google Reader
- "Now, Elvis, look, you get up there, you sing your song, but don’t move too much" | Yesterday
- Chart of the Day | 3 days ago
- What Do You Suggest? Exploring the Collective Lives of Google Users | 2 weeks ago
- Today's Extreme-er Font Dork Moment | 2 weeks ago
- REWARD | 2 weeks ago
recent photos on flickr
recent trips
- Returned from a trip to Los Angeles. | October 2009
- Started a trip to Los Angeles. | October 2009
- Returned from a trip to New York. | February 2009
- Started a trip to New York. | February 2009
- Returned from a trip to Rosario. | January 2009
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
on February 8, 2009, 1:25 am Robert said
Hi, if you could provide working link for console.as since link http://www.marcosweskamp.com/blog/docs/Console.as is not working.
on May 12, 2009, 9:44 pm calvin said
Your links are dead for Console.as , thanks for the article though useful this method especially since it seems soooooooooo freakin hard to get simple trace stuff coming out in the various non flash dev platforms.
on July 16, 2009, 7:52 am marcos said
OOps! Sorry, should be updated now. thx for your comments!
on September 22, 2009, 7:55 am Scott said
Still broken link for Console.as (forbidden)
your thoughts