Using TextMate for ActionScript 3 Development

Over the last few days I’ve been checking out TextMate to see how useful it is for Flash development. I can now report that I’ve found the most versatile text editor in existence. There are so many possibilities with this tool simply because it’s so extensible. I plan on eventually doing a tutorial on using it but for now, here are some things that I’ve learned.

The first step is obviously to download the latest version of TextMate. From there you should download the ActionScript 3 bundle which adds a whole host of templates, commands, and snippets that will help you write ActionScript with ease. This blog post has all the details of installing it. After installing the bundle, you can unleash the real power of TextMate by modifying the bundle and adding your own commands and snippets.

I added a command that allows you to hit Cmd-Enter to automatically save your project and switch to Flash to test your movie. This based on a command in the old ActionScript bundle but I have modified it to fit my needs. You can see the details of how to setup it up in the screenshot below.

I highly recommend anyone on OS X to download this editor and check it out as I think I will be doing a lot of my coding in it from now on.

Lee

Comments

  1. Dan
    May 3rd, 2008 | 12:42 am

    I’ve been using TextMate exclusively for the last 6 months or so, for writing all of my AS. So, I couldn’t agree more. Not sure how I ever did without it, honestly.

  2. May 3rd, 2008 | 1:28 am

    Sounds nice. :)

    Since I’m a Windows user I’ve been looking at similar tools. Lately I fumbled a bit with FlashDevelop. I especially like the code hints for newer like Papervision3D 2.0. Also there is a big community behind this app which makes for good support.

    Any other Windows editors you’d recommend?

  3. May 3rd, 2008 | 1:33 am

    And if you run Windows – http://www.e-texteditor.com

    TextMate is the award winning editor for MacOS X, that has revolutionized the way text editors work. By supporting TextMate bundles, e makes you part of a huge and vibrant community. Whatever task or language you need to work with, there is a good chance that someone has already made a bundle with all the needed adaptations.

    Haven’t had a chance to really test it, But looks good.

  4. May 3rd, 2008 | 1:48 am

    Hi there,

    I’m just wondering, does Textmate auto-complete your classes and standard classes? Because last time i checked i couldn’t make this work. I don’t use Macs that often, so it might well be that I didn’t do it properly.

    You know if this is possible? It seems i’m not the only one:

    http://www.visible-form.com/blog/flex-builder-vs-textmate/

    If this is true, i wonder where all the buzz about Textmate comes from, because if the best code editor for Macs _ever_ doesn’t auto-complete your classes… that’s disappointing!

  5. May 3rd, 2008 | 2:40 am

    I’m already using TextMate for other kinds of web development, but I never really figured out how to use it for Actionscript. That compile command was great. Looking forward to your tutorial! Will you be talking about alternate compilers like MTASC?

  6. May 3rd, 2008 | 3:11 am

    This is awesome, I can’t wait for the tutorial. I’ve been a huge TextMate fan for a while now, and never quite got the bundle to execute in flash correctly. Maybe you can also post on how to use MTASC to get textmate to code hint AS3.

  7. May 3rd, 2008 | 3:26 am

    “TextMate remains exclusive for the Mac, and that is how we like it!”

    Way to lose a huge market…

  8. May 3rd, 2008 | 5:00 am

    I am a big ignorant about Textmate – does it provide AS-specific code completion (both standard and custom classes)? What advantages does it provide over the Flex Builder to Flash workflow?

  9. May 3rd, 2008 | 5:30 am

    Thanks for the tip Lee!
    How’s the hinting and code coloring?

  10. May 3rd, 2008 | 6:05 am

    Thanks for the tip, Ive been waiting for an excuse for using Textmate since I bought it on a whim a few months ago… Now! Have you got any advice on getting round procrastination?

    Liam

  11. May 3rd, 2008 | 6:15 am

    I love FlashDevelop for this very reason. If you have a FLA open in Flash and an .AS file open in FlashDevelop and you hit [CTRL]+[ENTER] it launches the FLA (which obviously includes testing the code you are working on.) Does TextMate give you “intellisense” insight into your custom classes? For example, when you have instantiated a new object in AS does it display all of your properties and methods?

  12. May 3rd, 2008 | 9:16 am

    Great command Lee. I’ve been using TextMate for the last year and agree completely that it is the best “text editor” out there (I’m still partial to Coda for its more bundled project oriented features).

  13. May 3rd, 2008 | 10:28 am

    I’ve been using TextMate and AS2/AS3 bundles for a year now and I won’t go back – and even Flex is not for me. Well, there’s no REAL TIME code hinting (as in FlashDevelop, Flex or FDT), but you can complete any function when it’s saved in TextMate’s vocabulary (you can easily extend it).

    Sure, you have to remember everything, but that’s ok for me – if you don’t remember something, you can open your AS code base as a TextMate project or press CTRL+H to find more information in internal Flash CS2 / CS3 help or at Adobe’s online help site.

    Soon I’d be glad to write a small tutorial for UX Mag with a small screencast, but for now if you want more information about AS3 development under TextMate (= no MTASC), read more here:

    http://blog.simongregory.com/10/textmate-actionscript-3-and-flex-bundles/
    http://blog.danielparnell.com/?p=22
    http://blog.iconara.net/2007/02/23/textmate-flex-tips/

  14. May 4th, 2008 | 12:55 am

    TextMate is great but for advanced AS there really is nothing better than eclipse with FDT from Powerflasher. A bit complicatd to set up when you’ve got it you won’t regret it.

  15. German B
    May 4th, 2008 | 1:24 am

    For Windows the equivalent is:
    http://www.e-texteditor.com/
    a Textmate clone – even supporting Textmate snippets + commands.

  16. May 4th, 2008 | 9:30 am

    “TextMate remains exclusive for the Mac, and that is how we like it!”

    Way to lose a huge market…

    Not to say there isn’t a bit of mactionalism in the sentiment, but I believe there are actually also deep, ingrained code issues for porting TextMate to Windows, mostly that it’s so unix-centric that more than half of it’s features would be significantly different implementations, and might not even make sense in the Windows/.Net framework.

    Also, for those interested in TextMate and Ruby on Rails, there’s a great video tutorial site called peepcode (plug plug), who have a good introduction video to the power of textmate (for RoR).

    http://peepcode.com/products/textmate-for-rails-2

    If you know something about RoR, it would probably be worth the $9 charge for the video. If you don’t know anything about Rails and want to, peepcode has a good library of screen cast movies about it, which I’d recommend heartily.

    (note: I have no affiliation with Peepcode or TextMate other than being a happy subscriber and owner of their products)

  17. jjj
    May 4th, 2008 | 1:16 pm

    No offense, but you “just found” the most versatile text editor in existence? That sounds like a fairly absurd statement. Unless you made sure to check every text editor in existence.

    I check this site nearly daily and I really enjoy the tutorials, but there’s been a couple of these kinds of posts lately (Learning AS3.0 ” The Best ActionScript Book Ever Written”??) where you’re pimping a particular product making claims like it was your Grandma’s apple pie. Maybe it’s just how you talk, but it seems a little strange to me.

  18. Pierre
    May 4th, 2008 | 1:44 pm

    Hey Lee.

    I switched to Mac a few weeks ago and I was searching for a editor to replcae my fav in XP, FlashDevelop, after a few days of searching, I ended up with TextMate, which looks very promiseing. I using it the “hard way” with out any bundles.
    Looking forward to your tutorial on how to use it more effectively…

    Btw.. I´m loving my MacBook Pro… I´ll never switch back to PC…

    Sooner…

  19. lee
    May 4th, 2008 | 2:57 pm

    @jjj I have tried every major text editor and I know of no other that is as easy to modify to your own liking. The built in editor for creating commands and snippets is the most versatile that I have used. And as for the ActionScript book, I believe it is the best one ever written to this date. These are my personal opinions. If you don’t like reading them then just lose my URL.

  20. May 4th, 2008 | 9:56 pm

    I thought you were going to work on making flex and flash play better together :’(

    I might consider using TextMate for AS2 Development. I currently use XCode 2.5 with the language definitions for now. It would be cool if I could just flip a switch and have flex be in AS2 mode (pipe dream, i know). Actually, a better solution would be for those Clients stuck on flash 8 to let me publish flash 9 :P

  21. May 5th, 2008 | 6:29 am

    Hi,

    hehe, interesting post and I must say this text/code editor really looks great, but there is just one thing, it is not free. Then if I see that this text editor is not free I start to wonder why not buy Flex if I have to buy something, it probably costs more but it is Adobe product …

    Maybe you should explain to me why is TextMate better than Flex Builder.
    I see TextMate as competitor software to Flex. If you do not agree I would really like to hear your opinion.

    Must say I really respect your opinion, I love watching your video tutorials and I liked your AIR presentation in Geneva ;-) , so please do not consider my post as hostile.

  22. May 5th, 2008 | 8:35 am

    Hey, Lee, nice tip. But you just overrode a nice built-in command by assigning it to Command-Return. By default, the “Source” bundle (which is active in pretty much every type of document that you are editing, as is the “Text” bundle…be sure to check both out) assigns Command-Return to “Jump to the end of the line, then press return.” In other words, with your caret in the middle of line, start a new line below without breaking the current line. There are other handy variations: Command-Option-Return places a terminator at the end of the line (a semi-colon in ActionScript) if it needs one, and Command-Shift-Return jumps to the end of the line, places a terminator if needed, and then starts a new line.

    All pretty handy, and I sure understand the rationale behind the choice of key stroke, but I’d recommend Command-R, instead, as the typical key stroke reserved in TextMate bundles for “Run.” It’s a hold over from Xcode, but virtually every other bundle uses it. And that way you don’t obscure other useful, built-in commands. In fact, this is the command that works with the built-in ActionScript bundle.

    I’ve tried all of the (Mac) editors, too. TextMate is the only one for me. Those complaining about TextMate’s Mac-only deal might want to check out Sepy, at least for ActionScript development. If you want something more versatile on the PC, then “E-TextEditor” is supposed to be “TextMate for Windows.”

  23. jjj
    May 5th, 2008 | 9:00 am

    Again, I really don’t mean any offense, but you saying, “I know of no other,” is not the same as the definitive statement that it is the most versatile in existence. You’ve tried “every major text editor” (that you know of/in your language).

    If you said, “The most versatile text editor I’ve come across…” it would be a different matter. In your response to me, you clarify that it’s your opinion. Perfect. If it was written that way from the beginning you wouldn’t have to clarify it. You’re a trusted source. Whether they should or not, people come here expecting to get the inside word from “Adobe”. That’s all I’m saying.

    I won’t lose your URL, I enjoy news, insight and tutorials too much.

  24. May 5th, 2008 | 9:48 am

    I think intellisense (coding hinting) is completely underrated.

    Code hinting is to an object oriented reusable methodology as snippets are to a canabalizable/copy-able paradigm.

    It isn’t about forgetting functions and methods, it is about avoiding errors and facilitating inheritance and reuse.

  25. lee
    May 5th, 2008 | 10:25 am

    @jjj You said “Whether they should or not, people come here expecting to get the inside word from Adobe.” That is a mistake. People should come here to get my opinions, not Adobe’s. If I were to do that then I would simply say “buy Flash and Flex” instead of giving my honest opinion. That wouldn’t be good for anyone.

    @Dru Ahh I did not know that! I’ll have to remap that baby. Thanks for letting me know.

  26. May 5th, 2008 | 5:18 pm

    I love textmate. I use it exclusively for all web development on my Mac. And i agree with you, i have tried what seems like everything and TM is simply the best.

  27. May 5th, 2008 | 8:27 pm

    I want the best of both worlds (Mate and Flex). I love mate but I love the ability to command click on methods to jump to the source. The refactoring stuff is cool too.

  28. May 7th, 2008 | 2:08 pm

    thats for sure, man

  29. May 7th, 2008 | 10:47 pm

    Any of you guys got a good AS3 theme for textmate? I’ve been looking on the wiki, but wasn’t that impressed with any of them really

  30. May 9th, 2008 | 12:35 am

    I’m going to be the grumpy dissenter here.

    I try and try to like Textmate (It’s miles above most OS X editors, its project handling is a dream, and it truly is a great step in the right direction), but the huge love it gets from the community just seems to be a symptom of the tremendous lack of other options available: Yes, it IS a great editor, but no, it is in no way an acceptable replacement for FlashDevelop or other editors available on other platforms.

    Maybe the long-awaited TextMate 2 will address the issues, but until then…

    There is no real completion, the code browser is an external plugin that cannot be docked (it might as well be a separate program), and frankly, it feels like the editors I left behind three years ago on other platforms. It’s more powerful than BBEdit (big f*’in deal), and easier to use than Vim, and it’s expandable. However, its architecture doesn’t allow it to be expanded in the ways that matter most to me: I can’t dock palettes, add real-time completion, etc.

    For now, I’ll take the free, old-in-the-tooth, but infinitely expandable jEdit or the young, up-and-coming, OpenKomodo editor while I wait patiently for TextMate 2. To date, there’s nothing in Textmate that isn’t also available in jEdit. Sure hope that changes, though, as jEdit is not exactly what I’d call “zippy.”

  31. Joseph Magnani
    May 13th, 2008 | 12:18 pm

    I’ve been using Textmate for all my coding including, mostly AS3 for over a year now. I have to agree it is the most polished and versatile text editor out there for OSX — right now anyway. I want to like Flex, but it just feels kludgy and bloated. I do miss the code completion FlashDevelop provides. Hope that makes it’s way into Textmate 2+ in some form. It’s not horrible living without though, all the built-in keywords and any word on in the document regardless of language you are using complete by tapping ESC. I use that constantly.

  32. May 26th, 2008 | 1:27 am

    Hi!

    I’m using TextMate also but there is one problem witch I just can’t get around.
    Sometimes it seems as is flash cached the codes i edited in textmate. I add a simple trace somewhere and it just do not compile. I have to restart flash, to be able to see the changes…
    Is there anybody out there with the same problem? Or with any idea to solve this?

  33. May 30th, 2008 | 4:14 pm

    If anyone is interested in trace output while developing with TextMate, I’ve just posted an article on how to do this:

    http://bcdef.org/?p=30

  34. August 26th, 2008 | 7:42 am

    Whenever I run this command, Flash opens, but then crashes. Could you please briefly explain each of these commands so I can troubleshoot. The script I cam running…

    echo “document.testMovie();” > /tmp/fc.jsfl
    open /tmp/fc.jsfl -a “/Applications/Adobe Flash CS3/Adobe Flash CS3.app”

    Are there variables I should consider?

  35. September 14th, 2008 | 8:52 am
  36. NDL
    September 29th, 2008 | 3:42 pm

    @Alan

    Flash will crash with this script if it is not already open with a file to compile. Open Flash and open an .fla that you are associating with your code in textmate then hit cmd+enter and it will work for you.

  37. James
    October 4th, 2008 | 10:07 am

    “I love FlashDevelop for this very reason. If you have a FLA open in Flash and an .AS file open in FlashDevelop and you hit [CTRL]+[ENTER] it launches the FLA (which obviously includes testing the code you are working on.) ”

    Textmate has done this forever

  38. lauritz
    November 8th, 2008 | 12:06 pm

    thanks a lot for this great tip. now i made a little how to with mor edetails for those people that are new to textmate:

    How to use TextMate and Flash CS3 for building ActionScript 3 projects

    Note: You need to have a working installation of Flash CS3 and TextMate.

    1. Download flashcommand and unpack it.

    http://code.google.com/p/flashcommand/downloads/list

    2. Move the flashcommand file to /urs/bin. You may need to identify as admin to install it.

    3. Checkout the ActionScript 3 bundle from the TextMate SVN to /Library/Application Support/Textmate/Bundles (create the directories if they don’t exist):

    http://svn.textmate.org/trunk/Review/Bundles/ActionScript 3.tmbundle

    Note: If you don’t have an SVN client try Versions (http://www.versionsapp.com/)

    5. Open TextMate and go to Bundles -> Bundle Editor -> Show Bundle Editor and select the ActionScript 3 bundle.

    6. Click the Add-Button at the bottom and choose New Command. name the command Test Movie. Use the following settings:

    Save: All Files in Project
    Command(s):
    # requires flashcommand in /usr/bin. download it at: http://code.google.com/p/flashcommand/downloads/list
    # assumes the .fla file is already open

    echo “flash.getDocumentDOM().testMovie()” > /tmp/test.jsfl;
    open /tmp/test.jsfl;

    Input: None
    Output: Discard

    Activation: Key Equivalent and type Commmand + Return
    Scope Selector: source.actionscript.3

    7. To test your movie you have to open the fla in Flash and hit Command + Return in TextMate. That’s it!

  39. Omar Fouad
    December 1st, 2008 | 7:55 am

    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??

  40. Omar Fouad
    December 16th, 2008 | 1:47 pm

    Ok I’ve got a MacBook now and I have purchased TextMate but I am facing a problem as in I cannot target my flash projects to CS4 or playerglobal.swc. I really need to know how should I deal with this.

    I would be very grateful if someone could guide me.

    Cheers.

  41. March 31st, 2009 | 8:56 am

    [...] while ago Lee Brimelow posted about a way to publish flash files from textmate, but for some reason it never worked for me. Based on that method and some research into extending [...]

  42. danny
    April 6th, 2009 | 4:45 am

    nuts!
    i tried everything. i installed the as bundle and made also an cmd+enter-command.
    but its not working nor cmd+R nor cmd+enter :-/

  43. April 25th, 2009 | 5:32 am

    i made it!
    here is the updated version:

    echo ‘document.testMovie();’ > /tmp/fc.jsfl
    open /tmp/fc.jsfl -a /Applications/Adobe\ Flash\ CS3/Adobe\ Flash\ CS3.app

    and if you’re using newer flash, swith all 3s to 4s.
    for testing purposes, switch input to ’selected text’ and output to ‘replace selected text’

  44. September 24th, 2009 | 1:19 pm

    Holy balls thank you for this tutorial. Saves me a ton of time!

  45. llawson
    January 20th, 2010 | 3:27 pm

    Using OSX 10.4 and TextMate 1.5.9 I got the following to work:

    echo ‘document.testMovie();’ > /tmp/fc.jsfl
    open -a /Applications/Adobe\ Flash\ CS3/Adobe\ Flash\ CS3.app /tmp/fc.jsfl

    The modification was in the ordering of arguments passed to the open command. I think that may be due to using OSX 10.4

Leave a reply