October 30th, 2007

As a Flash developer who’s been working with Flex and ActionScript 3 since late last year I found I couldn’t settle down and use the Flex BuilderEclipse plug-in. Previously I had acquired the habit of editing ActionScript using TextMate and compiled using the lightning fast MTASC, and although there were alternatives (FDT, Sepy), I’ve always preferred the lightweight flexibility and crisp feel that TextMate has. As a result I’m responsible for TextMate’s ActionScript 3 and Flex bundles.

At the moment the bundles are in the review section of the TextMate Repository. Once installed the bundle help covers how to set up (primarily to download the flex sdk) and outlines the non-obvious commands.

The main highlights of the bundles are:

MXMLC and FCSH Build Commands.

Function, Tag, Import Auto Completion.

ActionScript 3 and Flex documentation search.

Drag and Drop of imports, includes, embed assets, css, xml.

ASDoc Support.

MXML Validation.

Manifest Generation.

Class and Component Templates.

Flex Builder compatible project creation.

Unused Import statement removal.

Shortcut Key Super Class, Code Behind and Import file opening.

Thanks to the following people who have all had a hand, although they may not know it, in the creation of the bundles:

Thanks for working on the Actionscript 3 bundle for Textmate! It sounds great. I have a request though. You have a few filenames in the bundle that are giving me difficulties when I’m trying to download. I’m using E-TextEditor on Windows and some files like “Getter:Setter” are not valid (I also saw a file that has a question mark in it). E-TextEditor is a great editor that works off the textmate bundle system. Most everything is compatable that I have worked with from Textmate to E. Would you mind changing these few filenames to keep compatability issues minimal?

q : I have a script which used to invoke the shell-script in the bundle to update as 3 library’s. But i yesterday discovered that this script is no more available. And I have no old as3-bundle copy anymore. Could you send me the script, so I can rewrite my script and publish it.

I love this bundle! It Rocks!
with the new revision, I am getting “parsemxmlcout.rb:31:in `+': can’t convert nil into String (TypeError)” when compiling. I believe it occurs when there are errors and they are trying to be displayed.
Any help is appreciated.

I did some Ruby learning last night and came up with an Eclipse-like Organize Imports command. Works for all .as files in the current TextMate project, so in this version it is necessary to drag the intrinsic classes to the project window.

The code is no doubt ugly as hell but let me know if you’d like to see it nevertheless. ;)

Jeff – Glad you like the bundle! I can’t recreate the problem you’re getting, I expect there’s a regex problem formatting mxmlc output. Until I work it out it’s possible to revert back to the previous python script by finding the following line in the build command:

It’s amazing: I’ve just uploaded a little bundle (FlexMate) I’m using, and then I found this post. :D

I’d like to use it – my Bundle can’t compete – but the current AS3 bundle here (downloaded by SVN) raises some issues for my usage style…

It sets a too high bar to start. It expects a saved project. Why? Mine just takes the current “project” and assumes it’s correct. It still makes some assumptions, but I shouldn’t have to make a project in order to compile MXMLC (I’m compiling directly AS files to SWF). I think you should allow “compile with assumptions” without a project (and giving errors, if anything is wrong) and allow customization if you’ll save one.

It doesn’t integrate with the FDB debugger. I’ve a task called “Make & Debug”, that spawns a Terminal window and runs FDB from there. I’ve found the Debug menu, but it doesn’t help (I can’t manage to get it working – maybe because I’m using Tiger?).

I don’t know since I can’t run it without creating a project (I can’t atm), but reading the Help: why didn’t you execute the TextMate builtin script in order to load the PATH environment? Again, I shouldn’t have to set another variable to do that, or use predefined directories. :)

I was really excited whan I found it, but at the moment it seems to me filled with usability issues. It doesn’t “just work”. ;)

I might help, at least adding the two features I’ve developed for my own use… and maybe working out those issues… since I’m sure that those problems are there in order to give more power to the Bundle, but they’re also limiting the ease of use. I think that everything could be perfect for everyone. ;)

Please, take anything you need from the very humble bundle I’ve linked above, and don’t hesitate to contact me if you want to collaborate. :)

Folletto – Thank you for the feedback and I’m glad you found the bundle. As it’s still in review by the TextMate community I’m more than happy to make changes that make it easy to use and understand. In response to your points:

Did you see the “Compile Current Class…” command? It should do what you need as it operates on the current file and isn’t project dependent.

You’re right! It doesn’t, and it should. I’ve been looking at your bundle for inspiration on this…. and hope to add something soon.

The majority of the bundle commands do use the $PATH if it’s been set, the main exception is the documentation command as the doc’s aren’t found in the bin. The point of using the predefined directories was to try and solve the “where’s the flex sdk” question before getting the user involved.

The main point of interest to me with your bundle is that you’re using the ScriptMate style approach. One of my TODO’s is to try and get this working interactively with fcsh – rather than running it “blind” through the Terminal or iTerm.

It works great, except for one thing. Whenever I attempt to build something, iTerm crashes on me, so I have to go to do my building manually right now. I’m using the latest version of the bundle from the macromates SVN repo. Have you seen this happen? Any suggestions?

Seems as though it is some issue with the applescript related to iTerm. BTW, I’m running 10.4. I just edited out the call to the fcsh build scripts and it’s working fine. It looks like you get a lot of pretty useful info from fcsh, however, so I’m looking forward to using this when I switch over to 10.5.

BTW, does this hook in the the flash debugger version at all, and it what ways?

Danilo – As long as you have set the TMFLEXFILE_SPECS shell variable correctly you shouldn’t have any problems. The best way to see how to set up a project is to create one using File > New from Template > ActionScript 3 > Project – ActionScript 3.

William – I know I haven’t kept up to date with the latest iTerm builds so that may be the cause of the problems. I’m now working from Leopard and Apple have improved the terminal enough to use it instead. FCSH is a great time saver, especially on large projects, but other than that it is simply a wrapper for mxmlc.

There’s work in progress regarding running fcsh inside TextMate, along with launching FDB.

It looks as though my automated script for exporting and zipping the bundles hung half way through the ActionScript 3 bundle export – so only half the bundle was included in the zip you downloaded. This has now been rectified.

thank you.
thank you SO much for this indispensable bundle!
i made the transition to AS3 yesterday, and am discovering a world of consistency :):):)
question: how can i get the project to use the …-config.xml in “build/”? i tried the custom compile, which told me “/build/compile.sh not found/executable”.

ok, before i posted this comment, i decided to do some research on permissions (being new to OS X shell deliciousness). might be a good idea to add to your help file that for custom compile, you need to execute

chmod -x ./build/compile.sh

i’m still mighty confused by the contents of that file, though…
where does it get TMBUNDLESUPPORT and the other path variables from? do i need to set all those manually? in TextMate preferences, or in my system? or does Textmate do that for me?

Although there’s likely to be additions to the the classes and methods used in Flex 3 I’ve not yet been through the code and added them. You can use the Flex 3 SDK without any problems as I have updated the appropriate commands in the the ActionScript 3 Bundle. However, at the moment, you have to manually override the environmental variable TMFLEXPATH and point it to the flex 3 sdk directory for this to happen. You can do this globally in Preferences > Advanced > Shell Variables or on a project by project basis via the Project Information panel reached via the i button in the project file draw.

I just wanted to let you know that I integrated an fcsh server in your bundle…

It opens a new textmate window with the fcsh running.
I then compile each class on saving, and get any build errors instantly (with links and error message, formated via ruby) in the fcsh window.
I managed to do this via a pipe, its still ruff around the edges but works fine for me.

If your interested in integrating it, do not bother to contact me via mail, and i’ll send you the modified bundle.

[…] I wanted a better way to import classes from my class library. The TextMate ActionScript 3 Bundle Simon Gregory offers a nice auto complete functionality that lets you define a list of classes to choose from on […]

Thanks so much for the bundle! This may be nit-picky, but I recently updated the bundle and found there are situations where, in for loops, I might have “i<=styleNames.length” as opposed to “i <= styleNames.length” (that is, one has spaces around “<=” and the other does not). This used to be parsed just fine by the syntax highlighter but now it seems it breaks it, so it and everything after it are not properly highlighted. I like to leave my spaces off sometimes.

So it looks like it gets the first path to mxmlc in the Flex SDK, but fails to get the rest of the arguments. I have tried using a single long arg line instead of multiple ones, and I’ve tried enclosing all paths in an extra set of quotes, but it’s not working.

I’m assuming that syntax coloring isn’t working because you have not associated your document with the language. This should happen automatically when you create a file with the file types .as or .mxml. However in the case of .as files you may find that TextMate associates the file with the default ActionScript (2) bundle. To manually change the language association select ActionScript 3 from the language pop-up in the document status bar (at the bottom).

Hello there,
Simon, do you know why if I use the custom set of index.html and swfobject inside your bundle, everytime I create a new project and after publish it, when I run (command+r), the index.html says me that I need flash player 9+, if I already have it…I have adobe flash cs3 installed on my mac and everything goes fines. but when try to run with your set of files I got this error. And when I try to public with flash player instead of index.html textmate says that cannot find de SAFlashPlayer application
Can you help me on this please?
Thanks

I’ve just run through creating a new project, compiling and running it and didn’t see any problems. I tested with the latest versions of the bundles (from the TM repository) in Safari, and when visiting http://www.macromedia.com/software/flash/about/ it reports i’m using the 9,0,124,0 player. Can you check what version you get when you visit?

Also, the SAFlashPlayer could be solved if you use the simpler open "$TMFLEXOUTPUT" line in the run command.

I’ve had it with Eclipse / Flex Builder – and want to get involved and contribute to using textmate + Flex.

But

For the life of me, I cant figure out how to do a simple compile of the Flex app. Is there a FAQ or walkthrough I’m missing. I’ve read some posts about using iTerm, but read others claiming it wasn’t nessesary. IS there a Flex compiler – or am I supposed to compile it as though it was an AS3 project.

Last – where do I put the SDK files….Should I be looking on the web for setting up AS3 projects and jsut apply it to the Flex bundle, or are there any other ‘catches’.

I absolutely love this bundle, but I find the ActionScript Project Template to be an exhaustive overkill for my needs.

I’ve tried cutting it down a bit in terms of files and folders created, but I keep messing it up so it won’t create the project. What’s the chance of a bare bones version of the AS3 Project template that includes only a src, bin and deploy folder and the bare essentials to be able to compile the swf? Alternatively a few pointers on where to gut the current template to suit my needs…

hi there,
i recently started using your Flex bundle, and i’ve noticed some sort of bug. Upon creating a new mx:Style tag, and pressing enter to separate the tags, Textmate gets into a loop consuming all the CPU and of course locking up the editor.
Is there any workaround for this?

Thanks for spotting that, it’s a pretty serious issue and it wasn’t limited to the Style tag the same was happening to the Script and Metadata tags as well. I think that it was down to using look ahead / behind regex matches to delimit an included language grammar. I’ve made some changes to the Flex language grammar so if you grab an updated version of the bundle from the TextMate repository the problem should now be fixed.

A question: After editing the build.xml and compile.sh files for custom builds (I’ve merely changed the deployment directory spec), the bundle no longer generates the supporting html and js files, nor the _assets directory. Do I need to specify this in the build.xml file or am I missing something…

Many thanks!

Also thanks to nemoDreamer for his post on changing the permissions on the compile.sh!

I’m guessing you’re used to Flex Builder so you need to know the AS3 Bundle is designed to simply generate the swf each time, and not the associated “deployable” files. Flex Builder (I’m rusty on this) will take any files it finds in the declared template directory and copies them to the bin directory when you build (if they’ve changed, are missing). It also offers a “clean” command which will delete the bin and copy all files in freshly.

If you want the same behavior I’d recommend that you look at building some custom ant tasks, or shell scripts which compile then copy the necessary files – rsync can be very handy here.

@Andy

You need to set the environmental variable TMFLEXPATH – see ‘Environment Variables’ (Chapter 9) in the TextMate manual for instructions on how to set these. Personally I store all the SDK’s in /Developer/SDKs/ and generally chose to control which one is used using project dependent vars.

One of the instruction was to clean the ant build using “ant -q clean”. DO NOT RUN THAT. It removes the fcsh.jar files and some other files that is required for the bundle to compile with mxmlc or fcsh.

I’m not sure why you’re getting the error with $TMFLEXFILE_SPECS, I’ have had another report that it fails so I have re-tested the bash code but can’t find a condition in which it fails for me. Are there any odd characters in the directory path? I did try it with spaces (which trips up fcsh) but that didn’t throw it off.

@Ali

There’s two things you can do, add the super() calls in your constructors if you have access to the code – generally I try and do this. Othewise you can modify the compiler settings, in the config file use:

Simon, I needed an instance of the fcsh shell for each project I had opened so I enhanced buildwithfcsh.sh to call fcshterminal with an extra parameter (I added an extra project variable calld TMFLEXPROJECT, but you may have a better mechanism). That extra parameter is used in fcshterminal to augment the FCSHWindowTitle to make it unique for each project. It seems to work well and wanted to see if you wanted to incorporate it.

FYI, I did this so I could do unit testing. I have one project with the test runner as the target class and one with the real target class. I didn’t like running one with fcsh and the other with mxmlc.

Thanks for making this bundle so awesome. I have just one request. I have fcsh setup and working now, but am looking for a way to put together a “build and run” command. Right now you have to manually watch the terminal and wait for fcsh to complete before you attempt to reload the browser. Doing this many times all day is tiring. Would be nice to hit one command and have it compile and run in one swoop as the flex ide does. There must be a way to tail the output of fcsh and wait for a success.

Thanks for thebug spot. I’ve been working on the full autocompletion functionality so haven’t used the “List Class Members” command myself for a while… a fix has been committed to the repository. Or, the offending line (18) needs changing to:

add “build and run” command that opens flash ide and tests the movie in the flash ide (just like the old actionscript 2 bundle).

add a command “documentation for selected word” to look up words in the doc files that come with the flash installation.

add a code “tidy up code” command that is cleaning up the code. this means remove unused empty lines, correct indention, add missing “;”, and throw out warnings when the syntax has errors. in fact the same functionality that has the “auto-format” button from the actionscript editor inside flash cs3.

the autocompletion is already very nice. but it would be even better when a little window pops up while typing, which dsiplays all possible completion words. maybe like coda?

if you get this all in i would pay $50 at least for the bundle. or you could make a free bundle and one that costs, but that has more features. contact me, maybe our agency can support your development with money.

Ok, now I am using e-TextEditor (Windows Vista) and I’m really frustrated. Code completion and snippets works just fine, but I don’t know how to set it up to build projects or classes to swf files… Any ideas??

hi, just noticed and wasted hours to find a small bug in your buildwithfcsh.sh script.

i tried to find the reason, why the message kept popping up, that iTerm is not installed, also it could be found, by another bundle-script.

so i found this:

[code]

Only check for iTerm when the OS is Tiger.

if [[ “$OS” == 10.4.* ]]; then

# this does not work .app is missing
# if find_app &gt;/dev/null iTerm; then
## identifier is also net.sourceforge.iTerm
if find_app &gt;/dev/null iTerm.app; then
#All is ok.
do_nothing_variable="TODO remove this by checking the negative"
else
echo "This command requires iTerm to be installed."
echo "See bundle help for more information."
exit 206;
fi

[…] I wanted a better way to import classes from my class library. The TextMate ActionScript 3 Bundle Simon Gregory offers a nice auto complete functionality that lets you define a list of classes to choose from on […]

I can’t use Leopard on an older machine, but would like to use fcsh. Seems like you removed support for fcsh through iTerm. I wonder if it would work if I used the oldest downloadable version of iTerm and the old bundle scripts that supported it. Can you make those old iTerm supporting bundle files available?

it doesn’t work, its not showing any warnings or errors, and it looks like it build the swf with no problems. but no swf is created. i believe some how the compiler is bailing before doing the hardcore stuff.

These features may be better suited for a Flash bundle. That’s with the exception of the formatting request, and I don’t have the time for the amount of work that would take at the moment.

If you grab the latest version of the bundle then this functionality is in an alpha state.

@Du Song – I try and use the first line regex match. This is unreliable though, and it means adding AS3 somewhere in the first line of every ActionScript 3 document.

@SimonL

In the bundle editor, select the project template and edit away.

You can change the settings in the compiler config file. You’d need to add false in the compiler node.

I had to drop support for iTerm and fcsh on Tiger I’m afraid.

What revision of the bundle are you using?

Type doc then press tab.

There aren’t any formatting tools available at the moment, once someone writes one that’s usable I’ll plumb it in.

@Omar Fouad – On Windows? I’ve no idea, if you work it out maybe you could knock together a quick how-to for other eText-Editor users?

@jens – sorry to hear you’ve had such a bad time debugging the buildwithfcsh.sh. As I’m solely running Leopard these days, and no longer use iTerm I decided to drop support for it. However looking at your change I imagine that you’d need to cover as many cases as possible when trying to detect iTerm for compatibility reasons.

@Marcos Zanona – I use it for external code libraries and swcs.

@Detrus – I removed the iTerm / fcsh support as I have no means to test that it works anymore and I’d had reports that it wasn’t reliable anyway. However if you need to then take a look at in the TextMate subversion repository before r11042 and you will find what you’re after. If you’re happy to keep this alive then you could fork the bundle on github.

@Webalab – Try setting things up manually on the command line and then use --config-dump to generate a correctly formatted compiler config file.

I’m trying to get a handle on using TextMate for my AS3 projects and am currently using it just to build out blocks of code that I’m then including in another file. I’m finding though that the syntax coloring doesn’t seem to like my code unless it’s in a package or class. Am I missing something here or is there some way to get this to work even for my classless code?

I find that when I switch the doc type over to Actionscript (and not Actionscript 3) the color coding seems to work fine. But this makes me a bit nervous…

@David – To get this to work you’d need to edit the ActionScript 3 Language Definition and add a specific scope for include files. At the moment it’s deliberate that it doesn’t work, but it shouldn’t be as having code loose is entirely valid. Editing the language definition isn’t the easiest thing in the world to do – so I’ll add it to my todo list. If you try please let me know if you have any success.

@David – Limitations in the TextMate grammar scheme (specifically that it only matches one line at a time) mean I don’t see an effortless way of getting include files to syntax highlight properly. It did occour to me that I could introduce an artificial ‘scope’ to get it working, so if you put this //AS3INCLUDEFILE comment at the top of your files, and make sure you’re using at least r11458 of the bundle then you should start to see things work.

> 1. In the bundle editor, select the project template and edit away.
I commented out a few mkdir’s as a test and then the bundle would no longer make a new Project. Last time I tried this I had to re-install the bundle.

> 4. What revision of the bundle are you using?
I’m not clear where to find the version no. but I had a copy from Jan 2009 and just installed the latest. I still cannot Apple-B to build.

>5. Type doc then press tab.
thanks
>6. There aren’t any formatting tools available at the moment, once someone writes one that’s usable I’ll plumb it in.

Well, formatting is a lot easier now and I have to re-iterate that this bundle is brilliant and being able to use TextMate has transformed my AS programming experience. thanks.

I find that if I edit the project template – ie. comment out a few of the extra mkdirs then I cannot create a new project. Uncommenting the commented mkdirs didn’t help get back to normal. Reinstalling the bundle fixed that but…
Then I find cannot compile a project. The only way I found to fix this was to delete the bundles , delete Textmate and start over.

I think this is what happened last time I tried to edit the project template.

I have installed the latest Textmate and the May 2009 build of the bundle. And latest Flex 3 builder with sdks.

I cannot Command B build and get a fcsh path not found error.

The path to the Flex Builder 3 install is identical with the value in the search path as reported in the error (/Applications/Adobe\ Flex\ Builder\ 3/sdks/2.0.1/bin). When i looked in the 2.0.1 SDK’s bin there is no fcsh.

This confused me as there is a fcsh in the bin of v3 of the SDK. So I copied it to v 2.0.1’s bin and still get the same error. I have checked the path to the bin in the terminal.

Then I remembered that I always used the ‘build using… mxmlc’ command on my old computer as I didn’t have iTerm. But this command and the build class command are not available in the menu and not listed in the bundle editor.

I’m not sure why fsch is not found and also why the install looks different with these commands missing. To get either working would be great if you can help please?

I will answer my own message (see above) in case anyone else has these troubles.

First – I now understand this is a brand new version of the bundle. My earlier one had the extra commands – which I assume are no longer needed. QUESTION. Where do we find standard documentation and version nos. for bundles (especially svn shy people like me) ?

I also can see that this new version is cleaner in having one Cmd-B, one way of building.

Second -with regards the fcsh path not found. I reinstalled fcsh from the installer on Adobe.com and then tested it from the terminal. It now worked. Then I went into the bundle’s build.rb and commented out these two lines:

#FlexMate::SDK.addflexbintopath

#TextMate.require_cmd “fcsh”

Then I added the path to the sdk bin directly in the textmate prefs in TMFLEXPATH.

After that back to normal.

I don’t really understand what was wrong with the path and if there is a better way of fixing this I’d like to know.

Also a question:

Can i make the swf auto open in a Flash projector if I choose instead of the index.html launching?

Any great work on the Bundle and I’m glad to have textmate/as3 back up on my new laptop.

I was used to compile with the mxmlc thing although, this fcsh seems to be faster…

Anyway, i just want to point something out, if you add any external folder to the project, the build command wont work. Right now im not entirely sure if im doing something weird or its a bug, but if i add any external folder to the project, cmd+b will throw a ” Missing Settings: The environment variable TMFLEXFILE_SPECS does not resolve to an actual file.”

hello all,
I see a lot of people here talking about the autocompletion.
Unfortunately I can’t see it working.
I’m used to work on Xcode with definition files and a projet template that tells where the compiler is.
That config rocks, the autocompletion works with actionscript built in function, plus the local variables and function names.
Is it possible to achieve this with this plugins, and how ?
Currently what I have is a TextEdit with colors and a Run button, it is a bit disappointing :(

A heads up…the reason the newest Textmate update broke the Import Class command was because the Textmate.eachtextfile implementation changed. In order to get it working again (and to avoid altering the textmate.rb file) I added the following function do source_tools.rb

hey simon,I’m a coder from china, and my english is not so pretty.so …you know ^^
first, this article is very good for me.^^
Back to topic.I’m fresh for usering textmate to develop as3 app. So I want to download the latest version of as3 or flex bundle, could you give me the svn address or some other address format, thanks.
secondly, I’m very eager to know how to configure this ide, so that I can start my as3 program. And I hava a presumptuous request, that is could you send me an email about the steps of the configure please.Thank you very very ……. much. thanks

Hi Simon, me , again. haha.
I’m feel very sorry to faze you. There is no need to read the questions I ask before. Because , I’v already fix them after I read the help.
But I steal got a problem. When I press cmd + B to built the program, the bundle commands search the directories which contains sdk. Finally it shows the path is “~$ /Applications/Adobe\\ Flex\\ Builder\\ 3/sdks/3.0.0/bin/fcsh” but “-bash: /Applications/Adobe\: No such file or directory” I think that there’s an additional ‘\’ in the path. So how could I fix this? thanks. And wait your reply

Hi. I have followed the SWC technique of placing it in the libs folder and then editing the appliaction config xml file with

../libs/

I have a single linked symbol myButton which I then try and use in main.as. The compiler does not see myButton as a class. It is not aware of it. How do we make the compiler link the swc’s classes?

As an aside, I love using the textmate/as3 bundle but I feel in general that I am missing the knowledge required to troubleshoot an issue like above. I’d like to understand the relationship between the bundle, it’s config files, app-config.xml, the build.xml, the various shell variables (and the various places they can be defined) and what gets passed to the fcsh/mxmlc compiler command. When running the build I cannot fully see what is happening and what shell vars and directives are in play. Is there some way to do that?