Datasheet
Luchner c01.tex V3 - 03/20/2008 2:29pm Page 9
Chapter 1: The Development Environment
Basic options were purposely included in the entered command, and in fact you could have entered
> amxmlc HelloWorld.mxml
and achieved the same result. For the purposes of this example, the
-load-
config
and
-output
options are included, as they are common settings you might override during com-
pilation of your application.
The
-benchmark
option can be added to display not only the operations that take place when generating
aSWFfilefromthe
amxmlc
compiler, but also the amount of time for each operation.
The
-load-config
option points to the configuration file to be read by the
amxmlc
compiler. It is included
here to show that you can specify a different configuration file for your project. You also have the oppor-
tunity to add a custom configuration to the
air-config.xml
file by specifying the following:
-load-config+=myConfig.xml
The
-output
option specifies the SWF file to which the application is compiled. When this option is left
out, the compiler defaults to naming the SWF file whatever the main MXML or ActionScript file supplied
as the file parameter. For the purposes of this example, the generated SWF is
HelloWorld.swf
.Notethat
the name of the generated SWF file must match the value given to the
content
element of the application
descriptor file. Therefore, if you override the default output, make sure that the name matches the SWF
that will be run within the AIR runtime for your application.
Also available are a handful of other options, which mainly involve adding SWC files to the library path
and including Runtime Shared Library (RSL) files. These are discussed as they relate to projects later in
this book but have been left out of this simple example.
Previewing and Debugging
The SWF file was generated using the
amxml
compiler, yet you have seen that the application does not
launch upon completion of that command, and opening the SWF file in the Flash Player does not display
anything other than the background color of the movie. To launch and preview the application, run
the AIR Debug Launcher (ADL) tool found in the
/bin
folder of your installation directory. A single
argument of the application descriptor file is needed to run the ADL. If you look at the descriptor file
(
HelloWorld-app.xml
), you’ll notice that the
content
value of the
initialWindow
element is set to the
SWF you previously compiled.
Open a command prompt, change the directory to the project development directory, enter the following
command, and press Enter:
> adl HelloWorld-app.xml
Your launched application is now running within the AIR runtime. Everything looks perfect and you
can see the text ‘‘Hello World’’ rendered in your label. You can run the ADL alone to preview your
application, but in developing a more complex application, you need some support for debugging. The
ADL has not been utilized to the potential from which its acronym is derived — AIR Debug Launcher.
To do so, first add a
trace
statement to the
HelloWorld.mxml
main file and recompile with the
-debug
option set for the
amxmlc
.
1. Open
HelloWorld.mxml
in a text editor and add the following shaded line:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
9