Flex 2 mxmlc batch compilation using ANT

By bootstrapping

(Warning: I am not a big fan of Flex 2 or Flash in particular)

I was working on a small demo for a client. This demo was requested to be built with Flex 2. So i downloaded the SDK and starting hacking around.

When i end up with quit a few mxml file, compiling them start to become a headache. Because for the stupidest reason mxmlc does not compile multiple mxml files at once. Unfortunately i had to use a Windows based machine for creating particular demo.

As the application back end was in Java, so ANT was my automatic choice for build. But the problem was how to compile multiple files with mxmlc

It was simple task if i was on Linux box as i am quiet familiar with bash scripts. At this point i started to look at how to write advance script in windows bat files. More specifically i was looking for a some sort of loop structure that can iterate over all the files in a directory. In the end i end up with following bat file:

batch-mxlc.bat

for %%m in (%1\*.mxml) do call "%FLEX_HOME%bin\mxmlc.exe" -output "%2\%%~nm.swf" %%m

This bat file takes two arguments, first one is the input directory where your mxml files are present. The second parameter is the path to the output directory where you want your swf files to be generated.

The ANT script is simple and easy it just uses the exec task

<target name="help">
<exec executable="cmd">
<arg value="/c"/>
<arg value="batch-mxmlc.bat"/>
<arg value="${input.dir}"/>
<arg value="${output.dir}"/>
</exec>
</target>

One Response to “Flex 2 mxmlc batch compilation using ANT”

  1. Pirsey Says:

    Not that I’m impressed a lot, but this is a lot more than I expected when I found a link on SU telling that the info here is awesome. Thanks.

Leave a Reply