Debugging Flex Applications on OS X

I had been under the impression that logging messages to a text file from Flex applications using the trace statement was not possible on a OS X, however I recently discovered that it works just fine, as long as the Flash debug player is configured properly. I’ll explain how to get it to work shortly. First, a little background:

Since Flex applications are not authored in the Flash IDE, they are a little trickier to debug than standard Flash applications in some respects. There is no output panel to capture and display debug statements from within your ActionScript code like there is in the Flash IDE. Thanks to the Flash debug player, however, Flex developers still have an easy way to debug their applications. The debug Flash player is capable of appending the output from trace statements to a local file, which is just as good — and in some ways better — than using the Flash output panel.

The issue, however, is getting this to work on OS X. OS X is not a supported platform for Flex, however it makes a very good Flex development platform, nonetheless (thanks to the fact that Flex is implemented in Java). Since it’s not a supported platform, documentation on debugging Flex applications on OS X is scarce, or possibly nonexistent. Fortunately, as I recently discovered, it’s perfectly possible. Here’s how to get it to work:

  1. The first thing you need to do is install the debug player. The debug player comes with Flash MX 2004, and by default, is located in /Applications/Macromedia Flash MX 2004/Players/Debug. Close all your open browsers and install the debug player, but don’t reopen your browser yet. The next step is to configure the debug player.

  2. Create a file called mm.cfg in the directory “/Library/Application Support/Macromedia”. The file should contain the following:


    ErrorReportingEnable=1
    TraceOutputFileEnable=1
    MaxWarnings=500

    There are many other options you can use to configure the debug player. See the tutorial entitled “Debugging Client-Side Code in Flex Applications” for more information.

  3. Open your browser now. You must open your browser after creating the mm.cfg file, and every time you make changes to the mm.cfg file, you have to restart your browser because the debug player only reads the configuration file once when it starts up.

  4. Put a trace statement somewhere in a Flex application, and load the application up in your browser using the debug player. To ensure the debug player was installed correctly, right-click (or control-click) on the Flex application, and make sure you see the “Debugger” option. It will be grayed out, which is fine, as long as it’s there. Now check in the same directory as your mm.cfg file for a file called “flashlog.txt”. It should contain the text from your trace statement.

To change the location of the flashlog.txt file, add the following line to your mm.cfg file (with the appropriate changes for your machine):

TraceOutputFileName=Macintosh HD:Users:cantrell:tmp:flashlog.txt

Notice that you must use colons (“:”) rather than slashes (“/”) as path separators, and that you have to give the full path, including the volume name (usually “Macintosh HD”).

While developing Flex applications, you might want to get into the habit of “tailing” your log file, which means using the “tail” command to keep an eye on it, like this:

[wednesday:tmp]$ tail -f flashlog.txt

The -f flag tells the tail command to refresh and show any additional data that is append to the file as soon it is written (as opposed to you having to constantly reload the file manually). Just keep a terminal window open as you develop, and you should be able to debug your Flex applications just as well as your Windows-using counterparts!