AsUnit for Flash – Entry 2

I wanted to mention a very useful feature in AsUnit that you may not have completely been aware of, even though it’s sitting right there. Right on the front of the AsUnit panel is a little checkbox which says “Show Sys.println”. I’ve seen it there every time I’ve used it, and figured it was some internal thing that I didn’t need to worry about while I was busy figuring out how to compare to non-Comparables. There’s also some mention of Sys.println somewhere in the docs or site.

Basically, you can use Sys.println anywhere you would otherwise use trace. The Sys class is installed right in the Classes folder, so it is automatically available from any script or class. Even if you don’t have the AsUnit panel open, you can still use it and it will work just like trace. However, if you do have the panel open, and check that litle checkbox that says “Show Sys.println”, you’ll see another text area open up above the default one. All your Sys.println messages will be printed out here instead of the output panel. I’ve started using this a lot, especially in asynchronous testing (which I’ll get to later) to say something like, “Connecting. Please wait…”

Another very cool thing about this is that you can send basic html to it. Add a bold tag or font color=”#ff0000″ to make the message really stand out.

There’s more madness to this method. Apparently, in quick perusal of the source code, you also send a category string after the message string. I’m not quite sure what that does yet. Perhaps someone who has dug a bit further than me can enlighten us. The Sys class also has a method called useExternalOutput which accepts a boolean value and seemt to toggle the output panel / AsUnit panel option manually. Since this all works with LocalConnection, I suppose you could write another whole app that hooks into the same connection and captures the messages as well.

Another little trick is that the AsUnit panel does not have to be opened as a WindowSWF in the Flash IDE. You can dig into the WindowSWF folder in Configuration and open it up in the standalone Flash Player. This will allow you to use Sys.println to trace things from a swf in a browser for example, or even from a non-IDE compiler such as MTASC. I’ve even considered using SWF Studio or Zinc to turn it into an executable to add some additional features to it, like forcing it to stay on top of other windows, etc.

This entry was posted in Flash. Bookmark the permalink.

2 Responses to AsUnit for Flash – Entry 2

  1. erixtekila says:

    More simpler with Eclipse :

    http://soenkerohde.com/2005/05/18/eclipse-with-netconnection-debugger/

    Because that trick will also work with the AsUnit window.
    And MTASC -trace switch could come to trace more things in addition?
    Nice isn’t it ?

  2. Keith Peters says:

    Nice solution if you are using Eclipse and MTASC.

Comments are closed.