Compiling SWFs with ANT + MTASC + Eclipse + FDT

The responsibilities of the tools involved:

Ant: Runs arbitrary commands on your computer. i.e.: Launch applications, run command line tools, FTP files, etc. in this case we are using it to launch MTASC and trigger commands in Eclipse to view a swf.
MTASC: Compiles ActionScript code and injects it into an exisitng swf file.
Eclipse: Acts as a platform and UI for running Ant and MTASC and viewing SWFs. MTASC does not compile swfs from flas.


We're going to use ANT to launch MTASC and compile ActionScript into an existing swf. Then call a command in Eclipse to view the swf file.


  1. Setup Eclipse and FDT (Ant should come installed with Eclipse.)
  2. Extract to C:\Program Files\hamtasc\
  3. Choose an existing Flash project in Eclipse or:
    1. Create a new Flash project in Eclipse
    2. Create a .fla file
    3. Compile your .fla to create a .swf file.
  4. Create a build.xml file in your Flash project.

    Example build.xml
    <project name="My Flash Build" default="Compile and Launch" basedir=".">
        <property name="target_swf" value="my_movie.swf"/>
        <property name="main_class" value=""/>
        <property name="mtasc" location="C:\Program Files\hamtasc\mtasc.exe"/>
        <target name="Compile and Launch">
            <antcall target="Compile Swf" />
            <antcall target="Launch Swf" />        
        <target name="Compile Swf">
            <exec executable="${mtasc}" dir="." failonerror="true">
                <arg line="-cp f:\"/>
                <arg line="-cp .\classes\"/>
                <arg line="-v -version 8 -mx -swf"/>
                <arg line="${target_swf} ${main_class}"/>
        <target name="Launch Swf">
            <dirname property="swf_path" file="${target_swf}"/>
            <fdt.viewDocument location="${swf_path}\${target_swf}"/>
  5. Make sure the
    property points to the swf you want to compile file, relative to the build.xml file.
    e.g. ..\my_movie.swf
  6. For whatever reason, you need to point to a class to make the compiler happy. Make sure the
    property points to a class. I haven't figured out why yet.
    e.g. com\package\
  7. Make sure the
    property points to your mtasc compiler. It already should if you followed the instructions.
    e.g. C:\Program Files\hamtasc\mtasc.exe
  8. In the
    node, under the "Compile Swf" target, make sure you add any class paths you need. The path can absolute or relative to your project.
    <arg line="-cp f:\"/>
    <arg line="-cp .\classes\"/>
  9. Open the Ant view in Eclipse. Window > Show View > Other...

  10. Drag your build.xml onto the Ant view.
  11. In the Ant View, expand the "My Flash Build" Node. You should see 3 targets (or commands): "Compile and Launch","Compile Swf", and "Launch Swf".

  12. Go to Run Menu > External Tools > External Tools...
  13. On the left, select your "Ant build" and click new. On the right, select the JRE tab. Then select "Run the same JRE as the workspace". Hit Apply then Close. Don't ask.

  14. In the Ant view, double click 'Compile and Launch'. Magic.

  15. At this point you'll see one of two things. A swiftly copmiled swf or a bunch of errors cause your code sucks.

Oh but there's more you can do!

Commands in ANT are called tasks. To launch MTASC we used the exec task. To view the swf file we used a custom task from FDT called fdt.viewDocument. Here's a list of other tasks that ANT supports:

Task Examples