kelvinluck.com

a stroke of luck

Excellent Flash debugging tool

Update 2:

This is a very old page imported from my previous blog. If there is missing content below or anything that doesn’t make sense then please check the page on my old blog.

much more up to date article on debugging from Flash.

The other day I came across the excellent luminicbox.log API for logging from Flash (english machine translation).

This is an API and debugger which will make your life as a Flash developer many many times easier. Rather than using the trace command you can Log messages to a LuminicBox.Log.Logger which will then use an “IPublisher” to output the logged message.

It comes with an IPublisher which outputs to the trace window in the Flash IDE (but pretty prints objects and arrays) as well as the really impressive “Flash Inspector” which allows you to view what the debug messages in a seperate swf. This swf communicates with your swf through a LocalConnection which means that you will be able to debug your application even after it is sitting on the live server. Yay :)

There is one little change that I wanted to make to it though. Whenever I write custom classes I override the default .toString method so that it returns a sensible name for each instance of that class. I wanted to have that displayed for each object that I logged when debugging… This would allow me to see at a glance what was going on in my application. While I’m at it, it would be nice to know how big an array was without having to specifically look at it’s .length.

First I set about adding this functionality to the TracePublisher class. This was easy enough – just change the following line:

txt += "(" + typeOf + ")";
 

to this:

txt += "(";
if (typeOf == "object") txt += o; // o.toString is implicitly called.
else if (typeOf == "array") txt += "array[" + o.length + "]";
else txt += typeOf;
txt += ") ";

Now when I Log my debug messages I see something like this:

*DEBUG*:(array[2]) {
   1:([Object com.kelvinluck.flickr.Photo - 6895531]) {
      contextThumbUrl:"http://photos7.flickr.com/6895531_23190e6e72_s.jpg"
      contextUrl:"/photos/lifeinpixels/6895531/in/photostream/"
      title:"Almost there"
      secret:"23190e6e72"
      id:"6895531"
   }
   0:([Object com.kelvinluck.flickr.Photo - 6895548]) {
      contextThumbUrl:"http://photos8.flickr.com/6895548_7993732d17_s.jpg"
      contextUrl:"/photos/lifeinpixels/6895548/in/photostream/"
      title:"Drop"
      secret:"7993732d17"
      id:"6895548"
   }
}

Now I want to add this functionality to the “Flash Inspector”. In fact, this is where it would be more useful. Because when you trace an Object or Array it is by default callopsed so it would be good to get a bit more information about the item without having to open it out.

Unfortunately I had a look and it looks like to add this functionality would require some editing in the “Flash Inspector” file which isn’t released with the source code. I suggested this improvement to Pablo (the author of this great tool) and he agreed it would be a good idea and is going to look into implementing it… Yay! In my opinion it would make something that is already really cool into something even more useful!

Anyway – props out to Pablo for writing this cool tool and I’ll update here if he makes the changes I suggested…

4 Comments, Comment or Ping

Reply to “Excellent Flash debugging tool”