Wednesday, September 07, 2005

AsUnit Meets XULRunner!

I've been researching XUL for the past few weeks and couldn't seem to answer all of the questions that keep coming to mind. I figured the only way to get it sorted out, was to build something in it, but I couldn't think of something that would be worthwhile and yet easy enough...


Enter "Create Class"

Since it's inception, I have had more than a few personal complaints about our implementation of Create Class. Thankfully, other folks have been really polite about it's shortcomings. I made excuses for it related to the limited implementation of XUL that is included with the Flash MX 2004 IDE (Among other things, It ONLY has XUL 'Dialog', NOT XUL 'Window')...

During recent months, I have become a sort of "Editor-Gigolo" and keep hopping from one to another in a desparate search for the "most amazing editor EVER".

Some environments that I have checked out include:


So far, each environment has some benefits and some drawbacks and I'm not 100% excited about any of them yet. I think that Emacs is the most promising, but it has a pretty high learning curve and causes some pain in my wrists with all the complex and repetitive key combinations! Right now, I'm settling into TextPad because it's fast, easy to launch from CygWin and it's really customizable.

Basically, in all this moving around, I have been dreaming about the day when AsUnit (and especially Create Class/Build Test Suites/Create Test Case) will work for me no matter what environment I'm using, and especially without regard to my operating system. (Even, dare I say, LINUX?!)

As it turned out, I kind of lost my mind over the labor day weekend and started rebuilding the functionality found in the AsUnit Create Class command and AsUnit UI Panel as a standalone XULRunner application. I thought I would just get a "beginning" in place and wound up building the whole damn thing!

I should probably hold off on releasing this until I make time to write an installer and some docs or something, but I just CAN'T WAIT!



So, without further rambling - if you're interested in the coolest utility to hit Flash development (in the past hour or so at least) - follow these (sort of) simple steps:


  1. Download the zipped files AsUnit 2.7 (alpha)

  2. Download the latest build of XULRunner from Mozilla.

  3. Unzip the createclass.zip file to somewhere on your system that won't change.

  4. Copy the com folder out of the unpacked classpath folder and put it into some directory that your compiler references. This should be either some place where you tell MTASC to look or if you're using the Flash IDE on windows, it will be somewhere like:
    C:\Documents and Settings\lbayes\Local Settings\Application Data\Macromedia\Flash MX 2004\en\Configuration\Classes

  5. Unzip the files you downloaded from Mozilla to some place that won't change. I put mine into:
    C:\Program Files\Mozilla\XulRunner

  6. Update your system PATH variable to include the location of xulrunner.exe
    On windows, this can be done by:

    • Using Windows Explorer, go to the folder that contains xulrunner.exe

    • Select the text that appears in the address/location field

    • Copy it to your clip board

    • Right-Click My Computer

    • Choose properties

    • Select the Advanced tab

    • Click Environment Variables

    • In the System Variables, choose the one that says, "Path"

    • Click the edit button

    • In the Variable Value field, go all the way to the right, add a semi-colon ";"

    • Paste the contents of your clip board into this field

    • Keep choosing OK until the panels all go away



  7. Open up a command prompt (Cygwin if you have it)

  8. Navigate to the folder where you unzipped createclass.zip, step into the xulCreateClass folder

  9. Enter:

    xulrunner application.ini

  10. Start Playing!





Some things you'll definitely want to try:

  1. Create or choose a working directory

  2. Add class paths to the UI

  3. Choose "Create Test Case"

  4. Choose "Make Class Serializable"

  5. Choose "Add __Packages Prefix"

  6. Select or Deselect "Show only interfaces"

  7. Keep opening the files that it creates!

  8. DEFINITELY choose "Private w/Singleton" in the modifiers section!



Once you have some class paths in there, you should be able to click "Choose" next to "SuperClass" and you should see every .as class that's available in your working directory and your classpath(s)... This also applies to the "Add" button for interfaces. Interfaces should be shown in blue in both of these lists!



Disclaimer(s) and random tidbits:

  1. This is barely ALPHA quality software! I hacked this out in three days as my first effort in XUL. Please don't set C:\ or your Desktop as the source folder! PLEASE create a new, empty folder and use that as your source folder.

  2. I have not run this even one time on a mac or linux, if you have either of these platforms, please let me know if it works!

  3. This should create error-free code for MTASC and the Flash IDE compiler(s), but the only templates that are current available are for MTASC compliance - since it's so much stricter...

  4. I *KNOW* that someone out there has (or wants to gain) experience building Firefox / Mozilla extensions, this is a perfect opportunity for you to contribute to an open source project! We're in desparate need of a good, solid XPI (Cross Platform Installer) so that when this is released, users can install it with a single click... Wanna help? Sign up to the asunit-users mailing list and let us know?

  5. I included anonymous CVS files in this release, so that as we iterate on the functionality, you can use CVS to perform instant updates to your local builds. This is kind of risky, so only do this if you know what you're doing. We'll be careful not to check in broken stuff to the head revision from this point forward...

  6. PLEASE let me know what you think of this by posting to the AsUnit mailing list...