Debugging Flex applications

Until yesterday it was fine for me using the integrated debugger in Flex-/Flashbuilder to debug my applications. It provides much comfort, nothing has to be configured, everything is fine.
But currently I’m working on an application which consists of several modules which are built using flexmojos and I had the strange phenomenon that my application worked in Flashbuilder but not when it was built by flexmojos.

A gentle person suggested me to use describeType() and see what happens. I had no clue what this meant so I needed some further information. Now I know more and can tell you 😉

Excerpt from ActionScript 3.0 Reference for the Adobe Flash Platform:

Produces an XML object that describes the ActionScript object named as the parameter of the method. This method implements the programming concept of reflection for the ActionScript language.

Ahh, I see, but how could I use this in my project? Where can I see the content?

First of all I chose the as3commons-logging framework for my logging. I use SpringActionscript in the project and this loggin framework is used there. To log my object I wanted to inspect I added this code to one of my modules:

import org.as3commons.logging.ILogger;
import org.as3commons.logging.LoggerFactory;
private function creationCompleteHandler(event:FlexEvent):void
var logger:ILogger = LoggerFactory.getClassLogger(ModuleSelectionPopUp);

Then I configured a trace target in my main application to control where the module debugs to:

import mx.logging.Log;
import mx.logging.targets.TraceTarget;
import org.as3commons.logging.LoggerFactory;
import org.as3commons.logging.impl.FlexLoggerFactory;
LoggerFactory.loggerFactory = new FlexLoggerFactory();

var traceTarget:TraceTarget = new TraceTarget();
traceTarget.includeCategory = true;
traceTarget.includeDate = true;
traceTarget.includeLevel = true;
traceTarget.includeTime = true;
traceTarget.filters = ["org.springextensions.actionscript.module.*"];

That’s it, my application was ready to create debug logs. There was only the last thing to do: having something which shows the logfile. I think there is a way to configure the FlashPlayer installation to generate a debug file but for me this approach is a little bit clumsy.
Fortunately there is the Firebug extension Flashbug which can be installed in Firefox. Flashbug traces the Flashplayer logfile and gives you a lot of information.

In my project Flashbug gave me the relevant information to solve my problem.


One thought on “Debugging Flex applications

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s