Debugging AS3 with firebug's console

firebug output

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, go:


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

not slacking!

sketch

way too much going on, this past year has been sleepless.
I've managed to take on a good bunch of monumental projects that have kept me quiet to the outside world.
Now that I see the light at the end of the tunnel, I'm definitively committed to flip that up.

expect updates, soon, very very soon...

Phidgets AS3

Phidgets AS3

Here's an Alpha AS3 rewrite of the AS2 phidgets Library. It's still very early on the developing process, but I thought I'd give everyone who might be interested a quick peek of what you can do with it.

download:

Source and Samples (756 kb)
SWC (Compiled code) (38kb)

you will need to have installed Phidgets.msi and have the PhidgetWebService running in order to properly connect to your phidgets. PhidgetWebService is a super light socket server to which your flash application connects to in order to properly send and receive data from all phidget components.

To install Source and Samples in Flex Builder I'd really recommend you to simply choose file> Import > Archive File > Choose the zip you just downloaded

If you want to go the SWC way, which is probably simpler, just create a new AS3 project in Flex Builder, Choose a name click next, and on the Library Path Tab click [ add SWC... ] and choose the location of the PhidgetLibrary.swc you just downloaded.

Things are still very dirty, If you have any suggestions on how to improve the code, please let me know.

I've done my best to resemble the original AS2 API as close as I could. Still, I took the liberty of creating extra objects that allow for even easier Phidget management.

There's no documentation at all yet, but there's plenty of samples to dig and learn how to use most of them.

If anyone out there wants tp give me a hand with docs I'd really appreciate it.
I'll try in the following days to write up some simple tutorials, so if you can't deal with the samples, patience.

code sample after the jump.

Embedding fonts in AS3

I love this! ... library, be-gone!

package {
	
import flash.util.describeType;
import flash.display.MovieClip;
import flash.display.TextField;
import flash.text.TextFormat;
import flash.text.AntiAliasType;
  
   public class Test extends MovieClip {
    
      // be sure this is pointing to a ttf font in your hardrive
      [Embed(source="C:\WINDOWS\Fonts\somefont.ttf", fontFamily="foo")] 
      public var bar:String;
      			
      public function Test() {
                	
          var format:TextFormat	      = new TextFormat();
          format.font		      = "foo";
          format.color                = 0xFFFFFF;
          format.size                 = 130;
						
          var label:TextField         = new TextField();
          label.embedFonts            = true;
          label.autoSize              = TextFieldAutoSize.LEFT;
          label.antiAliasType         = AntiAliasType.ADVANCED;
          label.defaultTextFormat     = format;
          label.text                  = "Hello World!";
          addChild(label);
       }
    }
}

AS3: attachMovieClip() no more!

aaah, "attachMovieClip"... just the sound of it sounds so retro already. plus... the library?! who the heck needs a library anymore?

kiss the library bye-bye!!
I'm sure we are going to remember these days with a lot of nostalgia.

package {
   import flash.display.MovieClip;
   import flash.display.StageAlign;
   import flash.display.StageScaleMode;
   public class Test extends MovieClip {
      // be sure this is pointing to an image in your hardrive
      [Embed(source='c:\images\whatsup.jpg')] public var MyImage:Class;
      public function Test() {
         stage.align     = StageAlign.TOP_LEFT;
         stage.scaleMode = StageScaleMode.NO_SCALE;
         var img:MyImage = new MyImage();
         addChild(img);
      }
   }
}

FITC Awards 2005 Winners

The winners where finally posted. I'm proud to announce that Flickr Graph won the experimental category!

I should probably mention that the night of the awards, to be sincere, I had almost zero hopes against Grant Skinner (who won for best Canadian Developer) - So much that the time they where opening the envelopes at the awards ceremony we where out having taco bell. aaah it was years since my last taco bell. So we finished our nasty burritos and went back to the ceremony, where Hoss was struggling with his voice and still messing up opening the wrong envelopes for the wrong categories. When we get in, everyone starts congratulating me. I thought they where kidding, but after the 6th person coming by and saying congrats! you won! where the heck where you?! I finally thought well, maybe it's true huh. - and it was.
Hoss handed me over my award once everything was done, and we went drinking. The award yep, it looks reaaaaly nice!

Thanks everyone! And of course kudos goes to ludicorp makers of flickr for making their API completely open and letting me play with it.

talby games

Everyone these days seems to be super busy!
really nice works by Tohsaki-san

talby - Be sure to play the talby domino game (click on the leftmost phone)
I love how in game #2 where you literally chat with a talby phone has all the intro explanation in english, and in the end it just tells you the game is only in japanese:P

also:
Victor Everio

NMNL ver1.0

NID gallery & fotologue.jp

the latest works from yugop & co.
Nagaoka Institute of Design gallery
and fotologue which is not really new but was just updated and relaunched today - I love the Explore More feature ;)

new marumushi.com

After years of slacking I decided to finally update the old and rusty marmushi.com. There's some processing experiments, and a new toy app flickrgraph.

So this is the plan, over there, you'll find a new newsfeed that I'm splitting now. This feed will be of a really loose character, and over there I'll try to stay as much focused in work as I can.

I'm also featured in the cover of shift

Sorry for the late post, I sent the link out to some friends, and left for Paris for the weekend. Now that I'm back I'm amazed on how the link to flickrgraph caught on, it seems to be all over the internet now. geez people chill out!

he, well, no, really thanx a ton.

the server was knocked out again a couple of times, but everything seems to be stable now.

a happy new year

2004, what a year. It first found me working in a skyscraper in Tokyo, took me to the suburbs of the city later, flew me to Germany, the Czech Republic, Austria and moved me to Italy. Took me back to school, woke me up for the first time and made me fall in love twice with the same woman. Got me to the beaches in Uruguay and ended in the green lawns of Argentina.

now I'm back in Ivrea, looking forward for another great year.
Yes, do expect more activity here, there is a ton of ideas and projects in the pipeline.

Let's rock 2005!