Building AIR applications with just the command line
I had a moment today where I wanted to find out some more information about Silverlight. I looked around but was unable to find any path to building the plugins with anything but the Visual Studio environment. That frustrated me quite a bit. At that point a friend pinged me to tell me a story of woe about his unsuccessful attempts to build AIR applications without one of the formal IDE’s. And while I had used the AIR SDK to launch and build HTML JS example applications I had never tried to build one using the Flex SDK. He challenged me to grab any example code on Adobe Labs and compile and launch the application using just the command line tools.
I accepted the challenge (beer me) and thought I should talk about how to build an AIR example application that was created in Flex Builder using just the free SDK tools. The first step is to actually download and install both the Flex SDK and the AIR SDK. I unzipped these folders and added the bin directories of each to my $PATH. Now I could execute any of the mxmlc or adl tools from the command line. Next I retrieved the source code for a flex based example application in AIR. After unzipping the the the source code and `cd`ing into the src directory I decided to just give a go at compiling the code. Using mxmlc gave me an error about the compiler no knowing what a WindowedApplication element was. So I added the air folder in the frameworks/lib directory of the flex sdk to my -source-path. Now my application compiled fine using the following command.
mxmlc -library-path+=/System/flex_sdk_3.0.0.477/frameworks/libs/air HTMLScout.mxml
This created a HTMLScout.swf file in the same folder as the .mxml file. Then after looking at the mxmlc options for a bit I realized I could skip that long scary path by just using the configname parameter.
mxmlc +configname=air HTMLScout.mxml
Which also compiled just fine. But just because Adobe knows that in general programmers are lazy, they also created the amxmlc executable which as you might guess, adds that config parameter for us. So to compile an MXML file inluding the AIR libraries we just
amxmlc HTMLScout.mxml
So now we have a swf that can be used as the content for our applications. Because when it comes right down to it AIR is just a wrapper for our content exposing a little more functionality than we have in the browser. So we can set the initial content of our AIR application to be any html or swf file. The trick here is that when using Flex Builder to create your AIR applications it sets the initial content property for you. But when compiling from the command line we have to have that set explicitly. So open up the application descriptor file for the example application you downloaded and look for this line.
<content>[This value will be overwritten by Flex Builder in the output app.xml]</content>
You need to change that to actually have a value that represents your base content. In my case the value needs to be:
<content>HTMLScout.swf</content>
Save that application descriptor file and use adl to launch your AIR application.
adl HTMLScout-app.xml
Sit back and bask in the glory of building applications that run on Mac, Linux and Windows for no cost at all. For more information please check out the following 2 pieces of documentation.
AMXMLC
http://livedocs.adobe.com/flex/3/html/CommandLineTools_2.html#1043794
Application Descriptor File
http://livedocs.adobe.com/flex/3/html/help.html?content=File_formats_1.html#1043413
04 Jun 2008 Simeon

This is exactly what I have been looking for! I spent hours trying to figure out how to build AIR apps with the free tools. There’s hardly any documentation on how to do it unless you are using the Flex Builder.
Thanks!
Glad I could help Marc. Ping back if you run into troubles.
sim