A problem occured while loading the plugin: krl_flickr_photoset -> : Assigning the return value of new by reference is deprecated on line 18
kelvinluck.com: Excellent Flash debugging tool
Get Firefox! creative commons

Excellent Flash debugging tool

UPDATE Please check out my much more up to date article on debugging from Flash./UPDATE

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:

ActionScript:
  1. txt += "(" + typeOf + ")";

to this:

ActionScript:
  1. txt += "(";
  2. if (typeOf == "object") txt += o; // o.toString is implicitly called.
  3. else if (typeOf == "array") txt += "array[" + o.length + "]";
  4. else txt += typeOf;
  5. txt += ") ";

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

PlainText:
*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…

  1. Kelvin,
    Thanks for your comments!

    I’m already adding your changes to the library, I’ll let you know then the new release is ready.

    I also have intentions to release the source code for the FlashInspector, so far the console is the most interesting item of the API.

    Regards!
    Pablo Costantini
    Pablo    Mar 28, 15:44    #
  2. Pablo,
    Great news! Thanks for the changes to the library and look forward to hearing about the new release :)

    Also very exciting to hear you will also release the source code for the FlashInspector – this will definitely be very interesting!

    Thanks again,
    Kelvin :)
    Kelvin    Mar 31, 06:27    #
  3. Have you checked out the AdminTool?

    http://acmewebworks.typepad.com/admintool

    let me know what you think!

    John
    John Grden    Apr 17, 01:37    #
  4. Hi John,

    Yes – I had checked out the AdminTool… It definitely looked really good but for some reason it wasn’t working with the file I tested it on… I’m actually on a road trip at the moment so won’t have a chance to test again for a little while but I’ll definitely try it again when I’m back and if I still have problems I’ll try and give you some info to help you debug the debugger :)

    Thanks,

    Kelvin :)
    Kelvin    Apr 24, 12:32    #