Media Art, User Experience Design, and Interface Development

Debugging Flash with Terminal or Command Prompt

Posted on 2011-02-26

All programming languages offer a way to debug and send some info to a console. In the Flash IDE, the traces are displayed in the output window, in Flash Builder/FDT/Eclipse the traces are sent to the console view. And so on.

That is useful while debugging, however most often those traces are needed in the final context of the Flash piece, like a website.

There are some awesome tools out there that do just that and in style. I’m thinking of De MonsterDebugger. That tool is really good, although it requires some additional classes and long words to write to get something simple (eg: MonsterDebugger.trace(this, "Hello World!")).

There is a context in which that tool cannot be used, and that is Facebook. Ah! the ever hatable social network platform! Facebook does not allow ExternalInterface for security reasons, that is why tools like De MonsterDebugger are not available, this is how data is sent to their debugger. Edit: After receiving a comment, I investigated, it indeed turns out that MonsterDebugger is available when working on Facebook, as it indeed uses LocalConnection. My bad for assuming. However, the use of ExternalInterface is still not possible on Facebook, and the point of this post is more to show how to use the Terminal and Command Prompt to debug.

Sure you could create a textfield and add it to the display list, but that can become tedious if you need to add scrollbars and such.

A good alternative is to use a debugger that functions regardless of context. Adobe’s open source Flex SDK comes with the Flash Debugger, a JAR package that can be run with Java from the command line.

Yikes!

That sounds more complicated than it really is actually. Let’s see how to run the debugger on Mac OSX and Windows.

Terminal on Mac OSX

The screenshot above provides already a lot of information on how to run that package, but let’s spell it out step by step:

  1. Open Terminal
  2. Go to the directory where of the Flex SDK you want to use
  3. Go to the “lib” directory
  4. In that directory, you need to run the “fdb.jar” package. To do so, type “java -jar fdb.jar”
  5. To start the debugger, type “r”, for run. The traces and errors will then be displayed in the Terminal

This will work for all SWFs published with debugging enabled, whether they are local or online, and that is where it becomes useful, for debugging stuff online. Just make sure then that you installed the debugger version of the Flash Player so it can communicate with the Terminal.

Command Prompt on Windows

It’s pretty much the same on Windows with the Command Prompt. You can see here that I use Windows XP, so I’m sorry if there are slight differences on Vista or 7, I don’t have those OSes.

  1. Open the Command Prompt
  2. Go to the directory where of the Flex SDK you want to use
  3. Go to the “lib” directory
  4. In that directory, you need to run the “fdb.jar” package. To do so, type “java -jar fdb.jar”
  5. To start the debugger, type “r”, for run. The traces and errors will then be displayed in the Command Prompt

Happy debugging!


2 responses to “Debugging Flash with Terminal or Command Prompt”

  1. guest says:

    ExternalInterface? Doesn’t it work via LocalConnection to debugger client app?

  2. Great information. It’s really useful. Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.