TextMate Flex tips

I’ve started working with Flex, and since I use TextMate I have written some useful commands which I thought I would share.

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

To use these, I suggest that you first install Daniel’s bundle. Then you create a new command, paste in the code below and set the other properties (Save, Input, Output, etc.). Perhaps one day this will be a bundle of its own, but not today.

Build with Ant

This command lets you use the standard TextMate key sequence for building, command-B to compile your current project with Ant. Since I work with Flash 8 projects too, I didn’t want to use this for ActionScript files, so it only works for MXML for now (it’s simple to change that, just add source.actionscript to the scope selector property).

#!/bin/sh

ant -find build.xml | perl -pe 's/\\n/<br />/'

Save: All Files in Project
Input: None
Output: Show as HTML
Activation: Key Equivalent command-B
Scope Selector: source.mxml

What it does is that it tells ant to search for a file called build.xml in the current directory (the directory in which the current file resides) and if it doesn’t find it to continue searching in the parent directory, and so on. When the build file is found Ant will run the default target and show the results in a new window. The Perl magick is to translate newlines to break-tags, since the output window renders the text as HTML.

Lint

Lint is another word for syntax checking, and since there is an XML syntax checker installed with OS X, why not hook it up to check the current MXML document when it is saved?

With this command you will get a message if your MXML-file isn’t valid XML when you save it. This saves you from having to wait for the compiler to tell you that you have forgotten to close you tags.

#!/bin/sh

xmllint --noout - && echo "XML syntax OK"

Save: Current File
Input: Entire Document
Output: Show as Tool Tip
Activation: Key Equivalent command-S
Scope Selector: source.mxml

You will see a tool tip saying “XML syntax OK” when you save MXML files, or an error message which tells you what is wrong.

MXML document checked with xmllint

5 Responses to “TextMate Flex tips”

  1. Vixiom Axioms » Set up eclipse to compile MXML / AS3 (quasi Flex Builder for OS X) Says:

    [...] just did a search and found some ‘Textmate Flex Tips‘ that extend the Flex [...]

  2. Iconara » TextMate Flex tips, part 2 Says:

    [...] been a while since I wrote about TextMate and Flex, but still my last post is one of the first five when I google for “textmate flex“, “textmate flex [...]

  3. andy Says:

    Ant?? Yuck!!

    Build with rake !!

  4. Theo Says:

    Since writing this, I too have seen the light.

  5. Matthew Wallace Says:

    Great post. Going to book mark this bad boy for later for sure. I have long sense wanted to switch completely to TextMate and use it 100% of the time. The problem that I am running into and I am sure others have as well is the fact that if you are on a project with other developers or you walk into an existing project 99% of the time they are using Flex Builder / Flash Builder.

    I am wondering if you found a way to configure TextMate to notice that you are editing an existing Flex project and compile / debug it via the command line successfully ?

    I short description on how to insure this to work and not mess up any project configurations / files would be great.

    thanks, -Matthew

Leave a Reply