There are plenty of tools out there to change the version information of a .swf file. However, I wanted to automate the process as part of my ANT build script, so I wrote a little Java class and ANT Macro to help me out.
You can download the .zip file here. Included in the .zip is the Java class and source code, as well as a sample ant build.xml showing how to use it. This is released under the MIT License.
Using the Java class inside of ANT is really simple:
<target name="updateVersion" >
<convertSwfVersion filename="MyApp.swf" version="8" />
</target>
<macrodef name="convertSwfVersion">
<attribute name="version" />
<attribute name="filename" />
<sequential>
<java classname="com.darronschall.SWFVersionConverter" fork="true" failonerror="true">
<!-- TODO: note the classpath here, you will probably need to change it -->
<classpath>
<pathelement location="flex/etc" />
</classpath>
<arg line="@{version} @{filename}" />
</java>
</sequential>
</macrodef>
The Java class is just a few lines. It simply seeks to the correct location in the .swf file and changes the header information. There's no error checking or anything, so use at your own risk.
A friend of mine had asked if I had written anything like this before. I knew that I had, and found it in my old archives after digging a bit, so I thought I'd put an open source license on it and make it available to everyone. If you find it useful, great. If not, well, at least I can find it easily by searching google instead of dusting off old archive CDs. :-)
Tags: ANT, Java, Flex
Nice. One addition could be to have your SWFVersionConverter extend the org.apache.tools.ant.Task so it could be used directly inside Ant.
Hi Dirk, feel free to make that change and re-publish it on your own blog. This was the easiest way that I could think of to get it to work - the Java file doesn't require any dependencies to compile (i.e. you don't need to add anything to the classpath).
This ANT script and your Java class works flawlessly to update Flash 7 SWF to Flash 8 file version.
However, we use ANT script only for deployment, at developer machines we currently compile Flex application in the run-time.
Therefore, my question is: Do you know any standalone tool to update SWF file version from 7 to 8?
I searched at Burak's site and it seems he does not offer any.
All you need to do is just invoke the Java class from the command line to use it "standalone" without ANT.