Some of my changes were not built correctly and I had a hard time debugging and checking whether the version of the swf I had deployed is the same with the latest version of my swf file.

Solution

I wanted to have an embedded code into the swf and display it into a label, at runtime. Browsing the internet initially, I’ve found some solutions using Python and Ruby. Having my build in maven, I decided to see what is provided by Flex, FlexMojos and Maven in order to facilitate that.

Analyzing the mxmlc compiler arguments I have found that I can define custom parameters into the compiler and read them from actionscript code. So I have defined a BUILD::buildNumber compiler variable:

Next, I had to change the compiler parameter for each build, automatically. Using Hudson as my Continuous Integration server, things got very simple. When a Hudson job executes, it sets some environment variables that can be used in build scripts. Among those variables there is BUILD_NUMBER.

The output of this, for a buildNumber 173 and a project version 1.0-SNAPSHOT is:

173-1.0-SNAPSHOT

The next thing I need to achieve, is to trick the browser’s cache, using this buildNumber, appending it at the end of the request for Main.swf, to end up automatically with a request like:Main.swf?173-1.0-SNAPSHOT.