Datasheet
Luchner c01.tex V3 - 03/20/2008 2:29pm Page 8
Chapter 1: The Development Environment
To top off this mug of magic, a
Label
component is included, with the
text
property set to
"Hello
World"
:
<mx:Label text="Hello World" />
With the
layout
attribute of the
WindowedApplication
tag set to
"vertical"
, this label appears centered
at the top of the container in the launched application. So far, discussion has concerned what will happen
once the application is installed and running. Now it’s time to launch it.
Compiling, Debugging, and Packaging
In the previous section you created the necessary files for compiling and previewing your application.
In this section you will use the command-line tools provided in the Flex 3 SDK to compile, preview, and
package your first AIR application.
Compiling
To compile the AIR application, use the
amxmlc
compiler found in the
/bin
folder where you installed the
Flex3SDK—forthepurposesofthisexample,thatis
C:
\
flex_sdk_3
\
bin
on Windows and
/Applications/flex_sdk_3/bin
onMacOSX.The
amxmlc
compiler invokes the
mxmlc
compiler with an
additional parameter pointing to the
air-config.xml
file found in the
/frameworks
folder of your instal-
lation directory. Compiling a Flex application using the
mxmlc
utility will load the
flex-config.xml
configuration file. The difference between the two configuration files is the addition of SWC files related
to AIR, including
airframework.swc
and
airoglobal.swc
. Take a look at the
air_config.xml
file within
the
/frameworks
folder of your SDK installation directory. The
amxmlc
compiler tool defaults to using
air-config.xml
, but you may also specify your own configuration file by using the
-load-config
com-
piler option.
To generate the application SWF file, begin by opening a command prompt. Change the directory to the
HelloWorld
project directory — for this example, that location is
C:
\
Development
\
AIR
\
HelloWorld
on
Windows and
/Development/AIR/HelloWorld
on Mac. Enter the following.
On Windows:
> amxmlc -load-config "C:
\
flex_sdk_3
\
frameworks
\
air-config.xml" -output
HelloWorld.swf HelloWorld.mxml
On Mac:
> amxmlc -load-config "/Applications/flex_sdk_3/frameworks/air-config.xml" -output
HelloWorld.swf HelloWorld.mxml
The
air-config.xml
option points to the location where you have installed the Flex 3 SDK. Compiling
the application with
amxlmc
produces a SWF file and does not launch the application on your system.
If you click on the SWF file created, you won’t see anything except the default background color. That’s
because it is running in the Flash Player, not the AIR runtime. You will launch the application using the
ADL executable file later in this section, as well as package the application for installation using the ADT.
To perform these operations, however, you first needed to generate the SWF file of the application using
the
amxmlc
.
8