Accessibility

TechNote (Archived)

Speeding up mxmlc

This TechNote shows how you can use Class caching, also referred to as SWO caching, to speed up command-line compilations of Macromedia Flex applications.

Caching SWO files is a way to speed up compilations by storing information on classes between compiles. This should work by default, but for a simple reason, this only works when compiling from the web and not when running mxmlc. There is a simple way to turn this on without actually touching Flex code and you can download the JAR that contains one class, flex.tools.FastMxmlc. This code is not supported by Macromedia.

Download fastmxmlc.zip(ZIP, 2K)

Using FastMxmlc speeds up compilations anywhere from 5% to 200%. This speedup only comes when you have a large number of classes that haven't changed after a previous compilation. It also depends on how many classes you have. If you have more than a couple of hundred classes, you could see more than a 200% increase.

The code in FastMxmlc is simple, and only has more than three lines in the main method because of a workaround needed to give the right error status on System.exit(). Because of this workaround, you do need to always specify the output file via "-o". Other than that, everything will work just as it does in mxmlc.

Here's a sample Ant snippet for using this JAR:

 <!-- location of webroot (and flexlib) --><property name="compile.webroot" value="apps/dev.war" /><property name="compile.flexlib" value="${compile.webroot}/WEB-INF/flex" /><!-- the file to compile --><property name="compile.file" value="${compile.webroot}/checkinTest.mxml" /><!-- location for SWF --><property name="compile.swfloc" value="${compile.webroot}/checkinTest.swf" /><!-- location of fastmxmlc.jar --><property name="compile.fastmxmlc"              value="${compile.flexlib}/lib/fastmxmlc.jar" /><!-- compile using FastMxmlc, a simple wrapper over flex.tools.Mxmlc --><java classname="flex.tools.FastMxmlc" fork="true" failon><classpath><pathelement location="${compile.fastmxmlc}"/><fileset dir="${compile.webroot}/WEB-INF/lib" includes="*.jar" /><fileset dir="${compile.flexlib}/jars" includes="*.jar" /></classpath><jvmarg line="-Xms32m -Xmx768m -Dsun.io.useCanonCaches=false"/><arg line="-o ${compile.swfloc} -flexlib '${compile.flexlib}'               -configuration ${compile.flexlib}/flex-config.xml               -webroot ${compile.webroot} ${compile.file}" /></java> 

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support

Document Details

ID:ad513439

Products Affected:

flex