flex and actionscript 3 with textmate and fcsh

Moving on to a new toolset to compile flex and actionscript on mac without flex builder. Fiddled around with XCode for a while. Then I decided that the compile times were too slow using mxmlc alone, and started using fcsh in the Terminal or iTerm. But that meant losing the convenience of compiling from within XCode.

Soooo, there’s TextMate, also a fine editor for the Mac challenged. And Joachim Van der Hoeven has put together a TextMate Bundle to compile mxml and actionscript 3 using fcsh (or mxmlc if you choose).

Installing the bundle is no problem, he gives you a script you can use to update the bundle on his site:

http://www.4d.be/update-as3-and-flex-bundle-script

The necessary ingredients:

Each of these can be installed relatively simply, in other words: if I can do it, anyone can. 😉

Things didn’t go smoothly right off the bat though. Some tweaks, or setup completion was necessary, at least the way things are set up chez moi.

First there seemed to be a problem with iTerm, so I got the latest version and re-installed that. Then I had to set the path to the flex sdk in TextMate, since by default the script looks for Flex Builder, which I decidedly don’t have, errh, don’t want to pay for. I also had to set the path for the -output parameter for mxmlc, since it’s at a different location than the project source files.

Setting these variables in TextMate is straight forward, once you figure out that it’s necessary. I needed to set these:

  • $TM_FLEX_FILE_SPECS (the file to be compiled, same as -file-specs when you use mxmlc on the command line)
  • $TM_FLEX_OUTPUT (the swf you get back, same as -output param for mxmlc)
  • $TM_FLEX_PATH (the path to where you installed the flex 2 sdk)

In TextMate, I set the $TM_FLEX_PATH under Preferences > Shell Variables, since that’ll be the same for all flex/actionscript projects. Then I set the $TM_FLEX_FILE_SPECS and $TM_OUTPUT at the project level, since that can change with each project, and since for the current project I need the swf in a different location than the source files (and probably for most projects, anyway).

That’s a little hidden. With nothing selected in the project drawer, click on the little i at the bottom. You’ll get a box to enter any variables you want for the project.

So far so good.

The one last thing to fix is getting the browser to open up at the location I need it to. With the default -output location (same as source files) the compile script was opening up Safari to display the newly compiled swf. That was nice. But it seems to have broken now that I’ve changed the -output location. :-((

That’s for another time. For now I’ll make do switching to the browser and refreshing the page I need.

Many thanks to Christoph for his post that first put it all together for me. danke! 🙂

Advertisements
This entry was posted in flash, actionscript, flex and tagged , , , . Bookmark the permalink.

16 Responses to flex and actionscript 3 with textmate and fcsh

  1. Peder says:

    How do you include .swc component files when compiling with TextMate fcsh? I tried throwing my swc’s into ~/Flex, but that didn’t work.

  2. freelanders says:

    Throw your .swc components into:

    flex_sdk/frameworks/libs/

    or add the path to your flex-config.xml:

    Path_To_Your_SWC

  3. freelanders says:

    Ooops. No XML-Tags in comments :-/
    (So I removed the brackets here)

    include-libraries
    library /libs/FisixEngine.swc /library
    /include-libraries

  4. lych says:

    If you’re interested. I created some time ago a wrapper around the flex compiler shell to use it with XCode. More info here :
    http://www.lpaudiolab.com/cpicasso/blog/projects/xflexwrapper/

    It is not perfect since i am not an intensive as3 coder, but it has worked for me for some projects. Everything is packed in a project template. Give it a try if you miss to much XCode.

  5. noah little says:

    merci charles, xcode fans will be happy to find that.

  6. Pingback: convert code in adobe flash 9 live docs to class file « noah little

  7. David says:

    thanks noah, it works great. If you are still looking for “getting the browser to open up at the location I need it to”: In TextMate open the Bundle-Editor and edit the ActionScript3-Run command. Here you’ll find for example

    open -a Safari “deploy/index.html”;

  8. dino says:

    The variable $TM_AS3_LIB_PATH may also be necessary depending on how your project is set up. It specifies the path to your classes for the current project.

    eg. with this folder structure

    projectFolder/
    source/
    projectFile.tmproj
    classes/
    dino/
    App.as
    deploy/
    outputFile.swf
    index.html
    swfobject.js

    my project variables are set up like this:
    TM_FLEX_FILE_SPECS classes/dino/App.as
    TM_FLEX_OUTPUT ../deploy/outputFile.swf
    TM_AS3_LIB_PATH /Users/dino/Development/flash/projectFolder/source/classes

    hope this helps …

  9. noah little says:

    Thanks Dino!

  10. KoPanda says:

    How can I add external libraries as default include path? And is it possible to run the swf as debug mode so that I can neglect the sandbox during development like what I do in flex builder?

  11. Pingback: rob.OT : compile as3 with textmate and flex sdk

  12. cp says:

    is there an update to this for flex 3? i love textmate and checking this out.

  13. Detrus says:

    Doesn’t seem to work. It could be the latest AS3 bundle, but there is no mention of iTerm in any of the build commands in the bundle. Instead it checks if your OS version is Leopard, if it is, it uses an fsch build .sh file, if not it compiles in mxmlc.

  14. Pingback: TextMate AS3 | [mck]

  15. Pingback: Nine Studio » Blog Archive » Flex及AIR开发资源集合

  16. Pingback: OTLABS BLOG » Blog Archive » compile as3 with textmate and flex sdk

Comments are closed.