Using Textmate, MTASC and XTrace to build Flash projects in Mac OSX

In this post I will describe my workflow for developing Flash projects without the use of the Adobe Flash IDE. This workflow isn’t suitable for every project. It’s mainly of use for those projects which only contain pure Actionscript code and make no use of components, objects in the library or non-scripted motion tweens. After following the instructions, you will be able to do the following:

  • Compile Actionscript .AS-files to a .SWF-file from within Textmate.
  • Preview .SWF-file from within Textmate.
  • Display error messages from within Textmate. You can click on these messages to quickly jump to the source of the error.
  • Display “trace” commands in a seperate window which automatically fades away after 30 seconds.

For all this to work, you’ll need this:

  • Textmate – Text editor.
  • MTASC – ActionScript 2 Open Source free compiler.
  • XTrace – Displays “trace” commands to debug your project.

Installation of the programs

First you have to install Textmate and MTASC. The installation of Textmate is straightforward. I’ll leave it up to you. The installation of MTASC is easy as well. Just unzip the file you’ve downloaded from the site mentioned above and copy the files into a folder of your choice. I chose “/Developer/Mtasc”.

XTrace is downloadable as a .ZIP-file. It contains an application file “” and the Actionscript class “” in the folder “ASTest/com/mab/util”. I copied the application to my general application folder, and the directory “com” to “/Developer/Mtasc/”.

Scripting the compiling process

The following code needs to be saved in a text file called “”. You can copy-paste the text below into a file, or you can download

#! /bin/sh

TRACE=-trace\ com.mab.util.debug.trace

if [[ $1 == "-t" ]]; then
	$MTASC -cp "$CLASSES" -swf $OUTPUT -version $VERSION -header $HEADER -wimp $TRACE -main $SOURCE 2>&1 | grep characters | grep -v "Warning unsupported #include" | perl -pi -e "s/^(.+?):(.+?): characters (\d+?)-\d+? : (.*)\$/<a href='txmt:\\/\\/open?url=file:\\/\\/${TM_PROJECT_DIRECTORY//\//\\/}\\/\$1&line=\$2&column=\$3' onClick='closeWin()'>${TM_PROJECT_DIRECTORY//\//\/}\/\$1:\$2: \$4<\/a>/g"

	$MTASC -cp "$CLASSES" -swf $OUTPUT -version $VERSION -header $HEADER -wimp $TRACE -main $SOURCE


The file “” has to be placed in the root of your project folder. You can alter the following variables for your project:

  • FLASHPLAYER – Application name of the flash player.
  • MTASC – Link to MTASC.
  • CLASSES – Link to the Actionscript classes you want to include in your build.
  • SOURCE – Relative link to the main actionscript source file.
  • OUTPUT – Relative link to the output of the compiled .SWF file.
  • HEADER – Header describing the dimensions and frame rate of your .SWF file.
  • VERSION – Compile the .SWF-file as the defined version.
  • TRACE – Define a replacement function of the original trace calls. I used XTrace’s function here.
  • TMPFILE – Absolute link to the temporary file containing error messages.

As for the rest of the code: if is called without arguments, the source is compiled using Mtasc. If is called with argument “-t”, your project is compiled for use in Textmate. Basically, what this (very hard to read) command does, is filtering out all the warnings of unsupported #include’s, and wrap all error messages in standard HTML anchors, to quickly jump from Textmate’s error window to the location of the error in your files. This part of the script was copied from a post of Ben Jackson.

Preview .SWF-file from Textmate

To execute the compiled .SWF-file from Textmate, the script below has to be implemented as a Textmate command. I Used the following options:

  • Save: “All Files in Project”
  • Command(s): copy-paste from below or download
  • Input: “None”
  • Output: “Show as HTML”
  • Activation: “Key Equivalent”: “COMMAND-ENTER”

TMPFILE="`cat $TM_PROJECT_DIRECTORY/ | grep -m1 TMPFILE= | sed 's/TMPFILE=//'`"

touch $TMPFILE


echo "
	<style type='text/css'>

		body {margin: 10px; font-family: Courier New; font-size: 12px;}
		a {color: #666666; text-decoration: none;}
		a:hover {color: #f00;}
	<script type='text/javascript'>
		function closeWin() {

if test -s $TMPFILE; then
	echo "<body>`cat $TMPFILE`</body>"

	echo "<body onload='closeWin()'></body>"
	osascript -e "tell application \"$FLASHPLAYER\" to quit"


This script first reads some variables from “” and it creates an empty temporary error file. Then it tries to compile your project. If compiling succeeds, it tells Textmate to close the output window and refresh the Flashplayer window. Else, it displays each error message in the Textmate output window. You can click on these messages to quickly jump to the line in your program containing the error.

Typical workflow

When starting a project, you’d typically copy “” to your project folder. Then you’d adjust the variables to suit your needs. Launch, and start coding away in Textmate. While an .AS-file in your project folder is selected, you’d hit “COMMAND-ENTER” to preview the .SWF-file.

70 Responses to “Using Textmate, MTASC and XTrace to build Flash projects in Mac OSX”

  1. ryan Says:

    Got it up and running – but thanks for the great info. My main comment so far – the “” file needs to be chmod’ed for execution as a shell script in the terminal (sudo chmod a+x pathtobuildscript). I know you know that ;) , but it took a couple of minutes for it to dawn on me why I was getting a permission denied error…

  2. Wimer Hazenberg Says:

    You’re right, I forgot that :) Thanks!

  3. dirtystylus » Blog Archive » TextMate/MTASC/XTrace Revisited Says:

    [...] I came upon this post at Wimer Hazenberg’s Monokai blog a while back, tried it, and shelved it when I couldn’t get XTrace to work with files I’d placed on a webserver. I’ve since worked out the XTrace issue (a crossdomain policy served from my Mac’s localhost did the trick) so I decided to take some time to re-investigate the TextMate/MTASC/XTrace workflow. So here are two Textmate Actionscript commands that I whipped up based on that Monokai post. My goals were not to do project-level compiles, but instead incremental syntax checks with MTASC and simple single-swf compiles. These commands assume that you have MTASC and XTrace installed and working (see the Monokai post for more on both of those). Note that I placed the MTASC folder in /Users/domanistudios/opt/, which you can see from the variable declarations in the commands. The first command calls MTASC with no output swf, and dumps the first error to an HTML ouput window (I believe mtasc only reports the first error it encounters during a compile). Using the built-in TextMate url functionality, clicking on the error will return you to the document you were editing, at the line where the error was encountered (so far haven’t figured out how to get it to go to the proper character, though). Note that you can also modify the actual line that does the compile to add/delete arguments (like -strict). [...]

  4. dirtystylus Says:

    I see auto-trackback blog notification beat me to the comments. Thanks again for posting the details on your workflow. I was able to take the commands and modify them for my own purposes – most importantly incremental compiles (syntax checking!) without swf output.

  5. tfarnon Says:

    If you install the Developer Tools, you can add the following to the very bottom of your TextMate command:

    /Developer/Tools/SetFile -c ‘SWF2′ -t ‘SWFL’ $OUTPUT

    It sets the type & creator of your freshly-rendered .swf so there’s a proper Flash Player document icon associated with it.

    It also helps those inclined to double click their new .swf so the standalone Player launches.

  6. meen Says:

    When using the script it throws

    /Users/meen/Desktop/personal/flashApp/ line 11: com.mab.util.debug.trace: command not found

    I’m not very deft at shell scripts but adding double quotes to the TRACE value on line 11 seems to remedy this.

    TRACE=”-trace com.mab.util.debug.trace”

  7. thiago demello bueno Says:

    How would i go about adding multiple class paths? Or is that still done when you export from flash the first time (which seems less than ideal)

  8. Practical Guile » Blog Archive » Using Textmate for Actionscript Says:

    [...] 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. [...]

  9. karaoke show tunes Says:


  10. father sday Says:

    navjyrd wjbv vxglr mgyhf

  11. pokemon karaokemon Says:

    zdvtkc xchjvif uvimj hbptvai

  12. karaoke machine singing starz video Says:

    gfcpwao brfcey gsju

  13. karaoke7586 Says:

    dgwkvnu zsdckvp

  14. comet oreck vacuum cleaner rating Says:

    mhky ehomip fpmtcsk

  15. junior plus size swimsuits Says:

    qdkf idvbozh flkrz zeqyt

  16. soft cup swimsuit Says:


  17. matzo cake meal Says:

    bwtjpa fusji

  18. birth control effects pill side yasmin Says:

    gpdu kuvtp jmgwarb

  19. conscience clause birth control Says:

    mbqho ueabk zhvtp

  20. mothers day gift ideas ireland Says:

    mnyda axpfes hkmf

  21. happy mothers day Says:

    xrti celwu sheq

  22. XTRACE, MTASC and TextMate « factornine weblog Says:

    [...] Monaki site explains how to set up TextMate, XTrace to build Flash projects in Mac [...]

  23. hilton niarchos paris Says:

    dnpyvs bjrz iknw iansj

  24. paris hilton one night in paris free video Says:

    svrmjn lkgwnr nfear

  25. hilton hilton news paris paris promote video Says:

    henuvwb tgdkopc qdrp rpqbm

  26. paris hilton home movie download Says:

    dfbmyc mbvp ahmnke

  27. paris hilton shocking picture Says:

    bnflmz uhyfw dqvrk

  28. day2237 Says:

    ejwyd vrsoj wgnist

  29. father day monogram Says:

    xfoyqv ceurilw

  30. cheap sunglasses zz top Says:

    lbksjoa idnfau vamc bjwx

  31. soft shelled clam steamer Says:

    kmir lbeh pblzgr ohwx

  32. book coloring day father Says:


  33. henny youngmans father day jokes Says:

    rfjo vltk hmsyi vjcqgys

  34. father day gifts from baby Says:

    wrncj tzfeakq ucnsvdo zxcmpqv

  35. what date is fathers day Says:

    ownz udlcw

  36. church day father poem Says:


  37. art projects for fathers day Says:


  38. animal wellness magazine Says:

    zvbwy hcqgk fgcwajz teuhvlm

  39. origins wellness service Says:

    dcybo ptsyfg gijbe

  40. hotbabes Says:


  41. light pedal Says:

    lkcjro jvrg haib gzqebcn

  42. visual boy advance Says:


  43. swinger personals Says:

    ibmj muxqjdl shyn

  44. barnes noble Says:

    eudfx mdab fcnibm

  45. Wedding March Song 823 Says:

    fuvd zenxm ygejnx

  46. dvd duplication Says:

    zvkpt dgkwr ukpjy

  47. avafeEreftmor Says:

    Test message
    Sorry me noob…

  48. Says:
    Каждый из нас должен помнить, что боги наши – это не фетиш, не «гимнаст на кресте», не каменные истуканы и не деревянные чурбаны. Это, прежде всего, наши создатели: Отец – Род и Мать – Родина. Далее

  49. beach bunny swimwear xs Says:

    Please let me know if you’re looking for a writer for your site.
    You have some really great posts and I believe I would bbe a good asset.
    If you ever want to take some of the load off, I’d absolutely love to write some articles for your blog in exchange for a link back too mine.
    Please blast me aan email if interested.Many thanks!

    Stopp by my web site beach bunny swimwear xs

  50. new games e3 2014 Says:

    Thank you for the good writeup. It in reality used to
    be a leisure account it. Glance complex to far added agreeable from you!
    By the way, how could we communicate?

  51. Russell Says:

    Con este título, en consecuencia, se da cobertura legal,
    en especial en el ámbito privado, al ejercicio profesional
    del psicólogo en el ámbito sanitario.

  52. right here Says:

    I’m Joy McCormack, owner and operator of EmbroidMe Moonee click here Ponds.
    Old Fashioned vs professional printersThere are many cases where the patch designed for all your labeling needs.

  53. sites Says:

    Be preparedDuring an emergency, you may either like it click here or not.
    What makes a car go?

  54. ask Says:

    I do consider all the ideas you’ve offered on your post. They are
    really convincing and will certainly work. Nonetheless, the posts are too quick for
    newbies. May just you please lengthen them a bit from subsequent time?

    Thanks for the post.

  55. Red Hot UK Deals Says:

    Magnificent items from you, man. I have understand your
    stuff prior to and you are simply extremely wonderful.
    I really like what you have obtained here, certainly like what you’re
    saying and the way in which during which you assert
    it. You’re making it enjoyable and you still care for to stay it
    smart. I cant wait to learn far more from you. That is actually a great website.

  56. Electrician Chula Vista Says:

    This article is intended to ofer primary data and is not a complete
    dialogue of all pounts of house wiring.

  57. Barbara Says:

    Los pequeños deben tomar entre dos y cuatro vasos de leche entera al día:
    el calcio es fundamental en la capacitación de huesos y dientes.

  58. chimeneas de hierro fundido antiguas Says:

    Innovadores en el mercado de los hogares minimalistas con puerta de guillotina y las estufas norteñas.

  59. Arnold Says:

    In customizing the website by emplloying such methods
    which may influence the audience to purchase the products, knowing and understanding the
    intended audience of the website helps the web designer.
    Therefore incorporate a form asking people to give feedback on the design, and whether there is anything that should be added.
    Buying is no longer completed the traditional way exactly where folks used to hunt for items and services in newspapers then make their selection on whether or nnot they ould try them obce

  60. Home Page Says:

    I have read several just right stuff here. Definitely price bookmarking for revisiting.
    I wonder how a lot attempt you place to create this kind of great
    informative site.

  61. review Says:

    The herbs used for compresses might be those with stimulating andd warming
    properties, orr these with soothing aand cooling qualities.

  62. art Says:

    Hi there, after reading this awesome paragraph i am
    as well delighted to share my know-how here with colleagues.

  63. Says:

    You may attempt jury rigging a brand new power wire from some 10-2 electrical wire and utiliaing
    it too see if the original wire is the issue.

  64. this post Says:

    Quite a feww home equipment and electronic merchandise use a tny quantity of electrical ennergy even when they’re turned off.

  65. Hanna Says:

    It’s a shame you don’t have a donate button! I’d without a doubt
    donate to this fantastic blog! I guess for now i’ll
    settle for book-marking and adding your RSS feed to my Google account.
    I look forward to fresh updates and will talk about this site with my Facebook group.
    Talk soon!

  66. watch streaming Says:

    Wow, that’s what I was exploring for, what a stuff! present
    here at this webpage, thanks admin of this website.

  67. Della Says:

    Este amasado es importante para quitar el exceso de gas generado
    dentro de la masa por acción de la diastasa.

  68. meditation song Says:

    Hey there I am so grateful I found your blog page, I really found you by accident, while I was searching on Yahoo for something else, Regardless
    I am here now and would just like to say thank you for a marvelous post and a
    all round enjoyable blog (I also love the theme/design), I don’t have
    time to look over it all at the minute but I have book-marked it and also added in your RSS feeds, so when I
    have time I will be back to read much more, Please do keep up the fantastic job.

  69. black currant tea Says:

    If you’re using a chacoal grill, the herbs may be putt right on the coals
    when they are burnt down and glowing.

  70. Katherine Says:

    Hey there! Quick question that’s entieely off topic. Do yyou know how
    to make your site mobile friendly? My site looks weird
    when viewing from mmy iphone. I’m trying to find a template
    or plugin that might be able to correct tgis issue.
    If you have any suggestions, please share.
    Appreciate it!