Instead of using Adobe Flash CS3, you may prefer to compile your Actionscript 3.0 classes using a command-line tool.
This article explains how to compile SWF files using the command-line tool “mxmlc.exe”, available from the Adobe Flex SDK. The tool is used to generate SWF files from Actionscript 3.0 (.as) or MXML (.mxml) files. Since we are going to use the Aspire UI library, we are only concerned with Actionscript 3.0 (.as) files.
If you have been using “mxmlc.exe” to compile your AS3 classes, which means you already have it on your system, skip this section.
The Adobe Flex SDK can be downloaded from http://www.adobe.com/products/flex/flexdownloads/
After downloading and extracting the Flex SDK, you can find “mxmlc.exe” in
%pathToFlexSDK%\bin\mxmlc.exe
For example, if you saved the SDK in C:\flex3sdk\, you will find the file in
C:\flex3sdk\bin\mxmlc.exe
Note that you will also need the Java Runtime Environment installed on your system. You can download and install the Java Runtime Environment from http://java.sun.com.
To use the “mxmlc.exe”, you need to open the Command Line Prompt Dialog (Start > Programs > Accessories > Command Prompt).
The syntax for using “mxmlc.exe” is as follows:
C:\flex3sdk\bin\mxmlc.exe -options targetClass.as
The above will generate a “targetClass.swf” file.
In order to use classes from the Aspire UI library, you must include the library using the -library-path option.
For example:
C:\flex3sdk\bin\mxmlc.exe -library-path=C:\aspireui\install\swc\AspireUISet1.swc targetClass.as
Remember that the compiled SWF will also need access to external files in the “assets” folder. If you want to test the compiled SWF offline, you must set -use-network=false (otherwise you will get a SecurityError when running the SWF):
C:\flex3sdk\bin\mxmlc.exe -library-path=C:\aspireui\install\swc\AspireUISet1.swc -use-network=false targetClass.as
Let's compile the HelloWorld class from the Hello World! example using “mxmlc.exe” instead of Adobe Flash (ie, no .fla file is required).
In the Command Line Prompt Dialog, navigate to where you stored the HelloWorld example files (ie, the “deploy” folder).
Enter the command:
C:\flex3sdk\bin\mxmlc.exe -library-path=C:\aspireui\install\swc\AspireUISet1.swc -use-network=false HelloWorld.as
A “HelloWorld.swf” file will be generated.
To set a specific SWF size, use the -default-size option:
C:\flex3sdk\bin\mxmlc.exe -library-path=C:\aspireui\install\swc\AspireUISet1.swc -use-network=false -default-size=300,300 HelloWorld.as
To replace the default “flex blue” background color with another of your choice, use the -default-background-color option:
C:\flex3sdk\bin\mxmlc.exe -library-path=C:\aspireui\install\swc\AspireUISet1.swc -use-network=false -default-size=300,300 -default-background-color=#FFFFFF HelloWorld.as