Clever::Tagline::Pending

Using Textmate for Actionscript

by Doug on Feb.10, 2007, under Software Development

I’ve never liked the default code editor that comes with the Flash IDE, so when the I discovered that I would need to develop actionscript code for a project, my first thought was to use Textmate instead. Incidentally, some people are already doing this.

I’ve used MTASC to compile Actionscript files before, the most important difference that surfaces when comparing it to Macromedia’s Actionscript compiler (MMC), which is the one that’s packaged in every installation of Flash, is that MTASC is much stricter on enforcing proper syntax. This is intended to reduce occurences of hard to find bugs that arise from improper scripting. The other feature that MTASC touts is its faster compile speed, however I’ve not experienced a visible variance between it and MMC. I would think that this speed improvement would be more apparent when compiling large projects consisting of more than 50 Actionscript files.

I’m using dirtystylus’ Textmate command for checking the syntax of my files, it took me a while to get it working as I organised the dependencies differently. Following my conventions in using MacPorts which is installed in /opt/local/, MTASC and XTrace were placed in /opt/local/managed/. The executable for MTASC was stored in /opt/local/managed/bin/ while XTrace.app was copied to the Applications folder. All supporting scripts were moved to /opt/local/managed/lib/.

This is the customised command that I’m using after trying for about 2 hours.

[code]
FLASHPLAYER=SAFlashPlayer
MTASC=/opt/local/managed/bin/mtasc
CLASSPATHS="-cp /opt/local/managed/lib/mtasc/std/ -cp /opt/local/managed/lib/mtasc/std8/ -cp /Users/douglas/Library/Application\ Support/Macromedia/Flash\ 8/en/Configuration/Classes/"
SOURCE="$TM_FILEPATH"
OUTPUT=test.swf
VERSION=8
TRACE="-trace com.mab.util.debug.trace"
TMPFILE=/tmp/as-compile.err
compileResult=`$MTASC -main "$SOURCE" -wimp -version $VERSION -strict $CLASSPATHS $TRACE 2>&1`
echo "

"
if test -n "$compileResult"
then
errorLine=`echo $compileResult | sed 's/.*:\([0-9]*\):.*/\1/'`
echo "$compileResult";
else
echo "
fi
[/code]


3 Comments for this entry

  • Mark

    You can also skip the XTrace bit altogether by installing the debug player and opening the log file via Console.app. Digitalflipbook has the how-to here: http://www.digitalflipbook.com/archives/2005/07/trace_from_the.php. This has a slight advantage over the XTrace route since it allows you to tap into trace ouput from non-MTASC compiled swfs as well.

  • Doug

    Thanks for the heads up, Mark. I get bothered by the number of hoops we have to jump through just to be able to work more easily in an environment other than the Flash IDE though.

  • Michael Lim

    Actually I found it easy to setup a Flex development projects in TextMate. Using Flex Builder 2 or Eclipse was way too slow on my system.

    Got the TextMate bundle from here:
    http://blog.danielparnell.com/?p=22

    Taking the bundle above, I modified the [dirs] paths to my include own Flex SDK dir,:
    dirs = [
    ...
    "/SDK/flex_sdk_2"
    ]

    And towards the end, modified the script to use Firefox instead of Safari:
    system(“open -a Firefox \”#{outputFile}\”")

    And yes, debugging from the Flash Player log file really saves a lot of time as well.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...