Compiling an AIR application with the amxmlc compiler
You can compile the Adobe® ActionScript® 3.0 and MXML assets of your AIR application with the command line MXML compiler (amxmlc):
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 mxmlc compiler and the configuration file format are described in Building and Deploying Flex 3 Applications in the Flex 3 documentation library.
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:
RunningMan-config.xml is loaded automatically since its filename matches that of the compiled MXML file.
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:
Compile and set the output name:
amxmlc –output anApp.swf -- myApp.mxml
Compile an AIR ActionScript file:
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 3 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
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