You can compile the Adobe® ActionScript® 3.0 and MXML assets
of your AIR application with the command-line MXML compiler (amxmlc).
(You do not need to compile HTML-based applications. To compile
a SWF in Flash Professional, simply publish the movie to a SWF file.)
The basic command-line pattern for using amxmlc is:
amxmlc [compiler options] -- MyAIRApp.mxml
where [compiler options] specifies the command-line options
used to compile your AIR application.
The amxmlc command invokes the standard Flex mxmlc compiler with
an additional parameter, +configname=air. This
parameter instructs the compiler to use the air-config.xml file
instead of the flex-config.xml file. Using amxmlc is otherwise identical
to using mxmlc.
The compiler loads the air-config.xml configuration file specifying
the AIR and Flex libraries typically required to compile an AIR
application. You can also use a local, project-level configuration
file to override or add additional options to the global configuration.
Typically, the easiest way to create a local configuration file is
to edit a copy of the global version. You can load the local file
with the -load-config option:
-load-config=project-config.xml Overrides global options.
-load-config+=project-config.xml Adds additional values
to those global options that take more than value, such as the -library-path option.
Global options that only take a single value are overridden.
If you use a special naming convention for the local configuration
file, the amxmlc compiler loads the local file automatically. For
example, if the main MXML file is RunningMan.mxml,
then name the local configuration file: RunningMan-config.xml.
Now, to compile the application, you only have to type:
amxmlc RunningMan.mxml
RunningMan-config.xml is loaded automatically
since its filename matches that of the compiled MXML file.
amxmlc examples
The following examples
demonstrate use of the amxmlc compiler. (Only the ActionScript and
MXML assets of your application must be compiled.)
Compile
an AIR MXML file:
amxmlc myApp.mxml
Compile
and set the output name:
amxmlc –output anApp.swf -- myApp.mxml
Compile
an AIR ActionScript file:
amxmlc myApp.as
Specify
a compiler configuration file:
amxmlc –load-config config.xml -- myApp.mxml
Add
additional options from another configuration file:
amxmlc –load-config+=moreConfig.xml -- myApp.mxml
Add
libraries on the command line (in addition to the libraries already
in the configuration file):
amxmlc –library-path+=/libs/libOne.swc,/libs/libTwo.swc -- myApp.mxml
Compile
an AIR MXML file without using a configuration file (Win):
mxmlc -library-path [AIR SDK]/frameworks/libs/air/airframework.swc, ^
[AIR SDK]/frameworks/libs/air/airframework.swc, ^
-library-path [Flex SDK]/frameworks/libs/framework.swc ^
-- myApp.mxml
Compile an AIR MXML file without using
a configuration file (Mac OS X or Linux):
mxmlc -library-path [AIR SDK]/frameworks/libs/air/airframework.swc, \
[AIR SDK]/frameworks/libs/air/airframework.swc, \
-library-path [Flex 3 SDK]/frameworks/libs/framework.swc \
-- myApp.mxml
Compile an AIR MXML file to use a runtime-shared
library:
amxmlc -external-library-path+=../lib/myLib.swc -runtime-shared-libraries=myrsl.swf -- myApp.mxml
Compile
an AIR MXML file to use an ANE (be sure to use ‑external‑library‑path for
the ANE):
amxmlc -external-library-path+=../lib/myANE.ane -output=myAneApp.swf -- myAneApp.mxml
Compiling
from Java (with the class path set to include mxmlc.jar):
java flex2.tools.Compiler +flexlib [Flex SDK 3]/frameworks +configname=air [additional compiler options] -- myApp.mxml
The
flexlib option identifies the location of your Flex SDK frameworks
directory, enabling the compiler to locate the flex_config.xml file.
Compiling
from Java (without the class path set):
java -jar [Flex SDK 2]/lib/mxmlc.jar +flexlib [Flex SDK 3]/frameworks +configname=air [additional compiler options] -- myApp.mxml
To
invoke the compiler using Apache Ant (the example uses a Java task
to run mxmlc.jar):
<property name="SDK_HOME" value="C:/Flex46SDK"/>
<property name="MAIN_SOURCE_FILE" value="src/myApp.mxml"/>
<property name="DEBUG" value="true"/>
<target name="compile">
<java jar="${MXMLC.JAR}" fork="true" failonerror="true">
<arg value="-debug=${DEBUG}"/>
<arg value="+flexlib=${SDK_HOME}/frameworks"/>
<arg value="+configname=air"/>
<arg value="-file-specs=${MAIN_SOURCE_FILE}"/>
</java>
</target>