Daniel Parnell's Stuff

Somewhere where I can muse about the things that interest me

TextMate and Flex 2

I’ve been having a bit of a play with Adobe’s Flex 2 command line compiler. After doing a quick search around the net I found a couple of hints for using it with TextMate. Unfortunately none of them did quite what I wanted, so I built my own. Hopefully it will be useful for others :)

TextMate bundle for Flex 2 coding

It adds a new language type for mxml files, a few snippets with mx as the tab trigger and a build command bound to Command-B.  By default it looks for your Flex install in the following places

  1. ~/Flex
  2. ~/flex_sdk_2
  3. /Developer/SDKs/Flex
  4. /Developer/SDKs/flex_sdk_2
  5. /Developer/Applications/Flex
  6. /Developer/Applications/flex_sdk_2
  7. /Applications/Flex
  8. /Applications/flex_sdk_2

Any errors or warnings are displayed in the output window and a click will take you to where the problem is.

Once your Flex app is building successfully it will be opened in Safari, or if you have a script called deploy in the same folder as your mxml file it will be executed instead.

Enjoy :)


49 Comments so far

  1. Karsten October 2nd, 2006 1:53 pm

    Hi Daniel,
    cool! I started to do one myself, but Yours is much better!
    I try to come up with some new ideas…

  2. Michael Wei October 9th, 2006 9:26 pm

    Thanks a lot, Daniel, you did a good job!

  3. Francis Fontaine October 18th, 2006 7:18 am

    Woa what a nice thing! it rocks!!!!

    But I add this trick to bind at Command-Enter for quick export :)
    I was wondering for two things…
    Since you can validate mxml, is it possible to make a quick validate syntax bind at Shift-Control-v just like in php (the result show in tooltip)
    And would it be possible to build the flex app in a different folder than the mxml file?

  4. Dylan October 23rd, 2006 8:03 am

    This is really, really fantastic. Have you contacted Allan Odgaard about merging this with future releases of TextMate? Thank you for sharing — maybe a Mac version of Flex Builder isn’t so important any more.

  5. Mathieu October 26th, 2006 5:04 am

    Thanks so much sir

  6. Jeff Self October 31st, 2006 8:52 am


    Great stuff! I just installed it but I’m getting an error when I try to build. I press command-b and get the following error message:

    Unable to access jarfile /lib/mxmlc.jar

    I have put the flex_sdk_2 folder in my home directory. The file I’m testing is in ~/Projects/flex/hello.mxml

    I can successfully build it from the command line:

    ~/flex_sdk_2/bin/mxmlc ~/Projects/flex/hello.mxml

    This produces hello.swf

    Any ideas?

  7. Alastair October 31st, 2006 10:36 am

    Dude this is awesome, thanks.

    I have a question about compile time, I have the beta of Flex Builder for the mac and it compiles projects in a couple of seconds while the SDK takes 10-30 seconds which is a looooooooooong time when debugging.

    I know the first time Flex Builder compiles it also takes a while but then uses some kind of caching. Do you know if there’s a way to speed up the SDK compile time?

    thanks again!

  8. [...] flexonrails.net flexiblerails.com (I’m half-way through the Flexible Rails book and so far it’s excellent) Adobe RIA RoR SDK WebORB for RoR Textmate Flex/MXML Bundle [...]

  9. Aidan Kane November 23rd, 2006 3:44 pm

    oh bless you and your fine little tmbundle of joy. people like you make coding worth doing.

  10. Chris Griffith November 29th, 2006 12:08 pm


    I ran into the same issue. I opened the bundle in Textmate and edited the Build Project Command section. You should see on line 10, “dirs = [”

    I removed the default paths, and inserted my own, “/Applications/Adobe\ Flex\ Builder\ 2\ Beta/Flex\ SDK\ 2/”0.

    Unfortunately, I get a Exception in thread “main” java.lang.NoClassDefFoundError: Flex error. Ugh


  11. francisco arenas December 8th, 2006 11:54 am

    yes! thanks indeed, its a great way to use textmate good job!

  12. [...] Flex and Ruby on Rails, two great Web 2.0 tastes that taste great together. I’ve been developing a personal Flex/Rails project for the last couple of weeks and I’ve found the fit between the two technologies to be very tight. Not only is there a Flex Bundle available for Textmate coders but since Flex Builder is essentially Eclipse it’s also very easy to install the Ruby Development Tools (RTD) plugin for Flex/Ruby integrated coding goodness. Also I’m finding scaffolding in Rails a pretty useful feature. Although my scaffold’s get quickly replaced with XML + Flex UI, they are great for initially testing the functionality of my Rail’s code. To get you on your way to your first Flex+Rails application I’ve compiled the following list of useful links: [...]

  13. Hipno-Blog » Flexing on OS X January 4th, 2007 7:17 am

    [...] Of course everyone’s favorite text editor: Textmate has a bundle for it http://blog.danielparnell.com/?p=22 (Thanks Daniel!) [...]

  14. Iconara » Blog Archive » TextMate Flex tips February 23rd, 2007 1:24 am

    [...] started by using Daniel Parnell’s Flex bundle, because of the language syntax, which I didn’t want to write [...]

  15. Andrew Shebanow February 23rd, 2007 9:38 am

    Here’s a patch to the BuildProject.tmCommand file, which lets it know about the default install paths for the Flex Builder 2 product and lets the user override with a shell environment variable:

    $FLEX_HOME = ENV["FLEX_HOME"] || “”
    unless File.directory?($FLEX_HOME) then
    dirs = [
    "~/Flex", "~/flex_sdk_2",
    "/Developer/SDKs/Flex", "/Developer/SDKs/flex_sdk_2",
    "/Developer/Applications/Flex", "/Developer/Applications/flex_sdk_2",
    "/Applications/Adobe Flex Builder 2/Flex SDK 2/",
    "/Applications/Adobe Flex Builder 2 Plug-in/Flex SDK 2/",
    "/Applications/Flex", "/Applications/flex_sdk_2"

    dirs.each do

    if File.directory?(dir)
    $FLEX_HOME = dir

  16. Niket February 23rd, 2007 12:18 pm

    Thank! Good Work

  17. karsten February 25th, 2007 3:05 pm

    Nice work, thx!!!
    Any plans to use fcsh?
    I don’t know how to communicate with it, though :(

  18. Ro March 19th, 2007 11:39 am

    What’s up, D. Fantastic plug in for textmate. However, there is still one issue that hinders me from leaving the Eclipse IDE all together, and that is the matter of linking external libraries. I write a toolset if you will of actions that i use over and over again, and link them externally to whatever project I am working on at the time so I don’t have to continuously rewrite them. In Eclipse, it’s just a simple matter of linking it to the project. However in textmate I have yet to find this crucial ability. Of course there are less elegant ways of getting around this, but I just wanted to post this in the hopes that you have been thinking about it as well. Thanks in advance, dude.


  19. [...] us. Flex 2 is all text based and although a bit XMLy for my liking isn’t bad. You can even get a Textmate bundle for it. Most importantly you can lob it all in version control. Better. Accessibility has also been [...]

  20. morganusvitus April 5th, 2007 7:29 am

    The site looks great ! Thanks for all your help ( past, present and future !)

  21. Martin Gilday April 6th, 2007 11:26 am

    I have downloaded and installed to Textmate, then manually added in Andrew Shebanow patch. I am still getting NoClassDefFoundErrors

    Exception in thread “main” java.lang.NoClassDefFoundError: Flex

    I have $FLEX_HOME pointing to my extracted SDK and $FLEX_HOME/bin is on my $PATH. Any ideas?

  22. Chris April 11th, 2007 8:13 pm

    I stumbled across this posting in my search for a free alternative to Flex Builder. Thanks to Textmate and this fantastic bundle I’m well on my way to producing some introductory Flex apps without having to make a $500 investment up front. The snippets included have already helped in streamlining production and I’m looking for even more help by introducing autocomplete functionality. I have an XSD file to pull from and was wondering if anyone knows if there’s a way to incorporate this into Textmate for code hinting MXML files. Any ideas?

  23. Jeff April 17th, 2007 9:38 am

    There’s a bug in this: when your Flex SDK is in a home dir, and you are using something like “~/Flex” to point at it, the script doesn’t do path-expansion and it can’t find the SDK. The fix is easy though… at the top of the code (line 10) replace this block:

    dirs.each do

    if File.directory?(dir)
    $FLEX_HOME = dir

    with this:

    dirs.each do |dir|
    fulldir = File.expand_path(dir)
    if File.directory?(fulldir)
    $FLEX_HOME = fulldir

    and the “Build” command should work fine.

  24. Josh Chaney May 4th, 2007 2:05 pm

    For some reason, when I compile my test.mxml app with the Textmate bundle, my HTTPService request in my app is never going out. But if I compile it manually from the command line like this ( from the flex2 bin dir ): ./mxmlc ~/Desktop/test.mxml, the HTTPService works fine.. what’s wrong here?

  25. Bolo May 11th, 2007 1:19 pm

    I patch my bundle but always same error
    “Exception in thread “main” java.lang.NoClassDefFoundError: Flex”

    dirs = [
    "~/Flex", "~/flex_sdk_2",
    "/Developer/SDKs/Flex", "/Developer/SDKs/flex_sdk_2",
    "/Developer/Applications/Flex", "/Developer/Applications/flex_sdk_2",
    "/Applications/Adobe Flex Builder 2/Flex SDK 2/",
    "/Applications/Adobe Flex Builder 2 Plug-in/Flex SDK 2/",
    "/Applications/Flex", "/Applications/flex_sdk_2"

    dirs.each do

    fulldir = File.expand_path(dir)
    if File.directory?(fulldir)
    $FLEX_HOME = fulldir

  26. Dethe Elza June 2nd, 2007 9:41 pm

    I’ve tried the above fixes, but I’m still getting the same error as Bolo. The rest of this bundle work really great–thanks for the effort you’ve put into it.

    If anyone found a fix to the proble of not finding the Flex class, I’d love to hear about it.

  27. Greg Jorgensen June 4th, 2007 12:58 pm

    I was getting the “Exception in thread “main” java.lang.NoClassDefFoundError: Flex” error. I have Flex Builder 2 installed under Applications.

    I found that I could compile my mxml file with the mxmlc compiler in the Flex SDK 2/bin folder, so I munged the Flex bundle like this (hard-coding the path to my Flex install):

    #MXMLC=”java #{VMARGS} -jar #{$FLEX_HOME}/lib/mxmlc.jar”
    MXMLC=”/Applications/Adobe\\ Flex\\ Builder/Flex\\ SDK\\ 2/bin/mxmlc”

    I’m not a Ruby guru, there’s probably some cleaner way to do this. The double-backslashes are needed to escape the spaces in the pathname for the shell.

    Works for me!

  28. flashape August 6th, 2007 9:39 am

    excellent work. I am having the same problem as Josh Chaney above, my HTTPService requests are throwing errors. any idea why this would be?

  29. flashape August 6th, 2007 10:26 am

    actually, I just noticed that it’s outputting to the same direcotry as the mxml flle…would you know how tochange the output path? (I’d just like to change it to ‘bin’ which is in the same directory that the swf is currently being outputted to).

  30. Steve Ametjan August 13th, 2007 3:37 pm


    The reason that the Flex Builder seems to compile the applications faster than the SDK is because the Builder will compile the project every time you save your MXML file. Then when you hit run, it just loads the already compiled SWF.

  31. Troy Gilbert August 28th, 2007 10:35 am

    @Steve Ametjan

    It may also be the fact that Flex Builder is Java-powered, so the overhead of firing off the compiler (which is Java-based as well) may be reduced (and in fact, on Windows at least, it doesn’t spawn a separate process) inside of FB, while the command-line builds/tearsdown a full process (including Java runtime) each time.

  32. Paul McMillan August 30th, 2007 6:04 am


    Good work; been trying out TextMate with Ruby/Rails recently and seems a good tool, this looks nice too.

    However, I had the same no class def found error and so changed the top of the script to the following, following a previous comment that didn’t work for me as written:

    #!/usr/bin/env ruby

    $FLEX_HOME = “/Applications/Adobe\\ Flex\\ Builder\\ 2/Flex\\ SDK\\ 2″

    VMARGS=”-Dapplication.home=#{$FLEX_HOME} -Xmx384m -Dsun.io.useCanonCaches=false”



  33. Paul McMillan August 31st, 2007 4:35 am


    One thing; if I want to use scripting in the MXML file; as this has to go in a CDATA section, there is none of the formatting you would find in a normal action script file in TextMate. Is there an easy way to combine the formatting so the code in the CDATA section looks like action script and not just a normal CDATA section? This would make things much clearer in the MXML file.

    Obvioulsy I could just move most of the action script to a separate AS file but it would be nice to have the best of both worlds :)


  34. [...] us. Flex 2 is all text based and although a bit XMLy for my liking isn’t bad. You can even get a Textmate bundle for it. Most importantly you can lob it all in version control. Better. Accessibility has also been [...]

  35. Hero November 8th, 2007 7:57 am

  36. Halo November 12th, 2007 2:37 pm


  37. Andrew November 21st, 2007 11:27 am

    Dan, this is an awesome little bundle. Flex Builder runs butt-slow, and it’s great to be able to use TextMate instead.

    @Jeff – thanks a bunch! I couldn’t get it to work without your path fix. Now I can build away.

  38. Elliott Sprehn December 3rd, 2007 11:15 am

    The JVM startup time is part of the performance hit with compiling with mxmlc, but the biggest issue is that by default mxmlc doesn’t use incremental compilation, and instead tries to recompile every source file in the entire project. Turning on incremental compile usually boosts performance considerably. There’s also the compiler shell which lets you keep building targets over and over from within the same JVM that keeps running.


  39. [...] TextMate and Flex 2 [...]

  40. Mawassuct May 14th, 2008 3:34 pm

    “Do you think what we’re doing is wrong?”
    “Of course it’s wrong! It’s illegal!”
    “I’ve never done anything illegal before.”
    “I thought you said you were an accountant!”


  41. naked Watch a nude Paris Hilton sex tape video…

    Recently leaked footage of the new Paris Hilton sex tape…

  42. Vinca Major May 23rd, 2008 4:45 pm
  43. Denver Tv Stations May 23rd, 2008 7:20 pm
  44. Amateur Cumshot Movie May 30th, 2008 2:47 am
  45. SOG knives July 17th, 2008 7:01 pm

    SOG knives…

    Interesting ideas… I wonder how the Hollywood media would portray this?…

  46. name August 31st, 2008 7:00 pm


  47. Edu September 7th, 2009 3:52 am

    Hi Daniel,

    I was using another TM bundle (feel ashamed) and recently discovered yours which is much better. I have a few suggestions / questions to you which I hope you could answer:

    1) Would be cool if you add a new environment variable where to add compiler specific parameters such as target-player, library-path, … Furthermore, maybe just a custom mxmlc args variable or so.

    2) Would be nice to have a build&run command

    3) There’s an issue with directory names with spaces (fcsh won’t work). I have a workaround which consists on cancelling the build, then launch fcsh from project’s directory (manually), and run the first mxmlc command manually just using relative files such as mxmlc -o=MyApp.swf MyApp.as. From this point every build command will work (since compile 1 is used). Would be possible to kind of automate that? Force terminal launch under project’s directory?

    thanks a lot for your excellent work!


  48. MDAttedsTeesk November 23rd, 2009 11:53 pm

    http://annlistens.com/ – alprazolam xanax
    Sudden discontinuation may lead to seizures.
    alprazolam mg
    Taking it in the morning will help you all day long.
    xanax online
    Psychological and/or physical dependence can manifest event if Alprazolam is used as recommended making it very difficult to discontinue treatment.

  49. [...] I am planning to purchase a mac and I was wondering if there was any development tools like Flash Develop for a mac w/ code completion and what not.||| You can get Flex Builder for the mac if you want. I personally use TextMate ( http://www.macromates.com). There are some plugins developed for TextMate that help with the flex development. You can find the most popular one here: http://blog.danielparnell.com/?p=22 [...]

Leave a reply