Saturday, February 10, 2007

Debugging in Flex 2

Until now I have been adding Alert.show() statements in ActionScript to help me debug my Flex application. This is very cumbersome, so I tried to figure out how to enable trace() statements that would write messages to a local log file.

I couldn't find any up-to-date instructions, but here is what I was able to piece together for Firefox on Windows at least:

  1. Download and install the latest debug version of the Flash plugin.
  2. Create or edit the mm.cfg file (located in C:\Documents and Settings\<user>\ in Windows). The file should have these three entries:
    TraceOutputFileEnable=1
    ErrorReportingEnable=1
    TraceOutPutFileName=c:\Documents and Settings\<user>\Application Data\Macromedia\Flash Player\Logs\flashlog.txt
  3. Install the FlashTracer extension for Firefox.
  4. Restart Firefox

Prior to the latest player revision it was necessary to set the HOMEDRIVE and HOMEPATH environment variables, but apparently not anymore. Also note that it is not possible to simply change TraceOutPutFileName to another location.

You do not need to compile your Flex application with the -debug option to use the trace method.