Tuesday, June 19, 2007

Bug in Flex mxmlc Compiler?

Flex Ant is a tool to build Flex projects using Ant. You can automate builds by using these Ant scripts. I've recently started using it and it works great! Except for one little thing.

In every Flex project there is a folder: html-template. This folder contains all the templates required to create the html wrappers around the out .swf that the Flex project creates. The most important file is index.template.html.

For example, if your index.html (the wrapper for index.swf) needs to contain a few javascript functions, all you do is add those functions in index.template.html. Then, every time you compile your Flex project, the new index.html is generated from the index.template.html file. Pretty neat!

But, when you want to do this with Flex Ant and the mxmlc compiler, no matter what customizations you do in index.template.hml, they do not appear in the output index.html file. Apparently, the command line mxmlc compiler does not look at the index.template.html file when its building the index.html file. I have searched all the documentation, but there is no way to specify which template file to use while compiling (there IS a 'template' attribute, but is for determining flash-client install options, history management, etc.)

So, the only workaround for this is to hard code the javascript functions in index.html and check them into version control. And not generating the html in the ant process.

If you anyone knows how to do this, please post a comment. That would be a very useful thing.