Creating your first HTML-based AIR application with the AIR SDK
For a quick, hands-on illustration of how Adobe® AIR® works, use these instructions to create and package a simple HTML-based AIR “Hello World” application.
To begin, you must have installed the runtime and set up the AIR SDK. You will use the AIR Debug Launcher (ADL) and the AIR Developer Tool (ADT) in this tutorial. ADL and ADT are command-line utility programs and can be found in the bin directory of the AIR SDK (see Setting up HTML development tools). This tutorial assumes that you are already familiar with running programs from the command line and know how to set up the necessary path environment variables for your operating system.
Create the project files
Create the AIR application descriptor file
To begin building your AIR application, create an XML application descriptor file with the following structure:
<application> <id>…</id> <version>…</version> <filename>…</filename> <initialWindow> <content>…</content> <visible>…</visible> <width>…</width> <height>…</height> </initialWindow> </application>
This example only sets a few of the possible application properties. For the full set of application properties, which allow you to specify such things as window chrome, window size, transparency, default installation directory, associated file types, and application icons, see Setting AIR application properties.
Create the application HTML page
You now need to create a simple HTML page to serve as the main file for the AIR application.
Your HelloWorld.html file should now look like the following:
Test the application
To run and test the application from the command line, use the AIR Debug Launcher (ADL) utility. The ADL executable can be found in the bin directory of the AIR SDK. If you haven’t already set up the AIR SDK, see Setting up HTML development tools.
First, open a command console or shell. Change to the directory you created for this project. Then, run the following command:
An AIR window opens, displaying your application. Also, the console window displays the message resulting from the air.trace() call.
For more information, see Using the AIR Debug Launcher (ADL).
Create the AIR installation file
When your application runs successfully, you can use the ADT utility to package the application into an AIR installation file. An AIR installation file is an archive file that contains all the application files, which you can distribute to your users. You must install Adobe AIR before installing a packaged AIR file.
To ensure application security, all AIR installation files must be digitally signed. For development purposes, you can generate a basic, self-signed certificate with ADT or another certificate generation tool. You can also buy a commercial code-signing certificate from a commercial certificate authority such as VeriSign or Thawte. When users install a self-signed AIR file, the publisher is displayed as “unknown” during the installation process. This is because a self-signed certificate only guarantees that the AIR file has not been changed since it was created. There is nothing to prevent someone from self-signing a masquerade AIR file and presenting it as your application. For publicly released AIR files, a verifiable, commercial certificate is strongly recommended. For an overview of AIR security issues, see AIR security.
Generate a self-signed certificate and key pair
From the command prompt, enter the following command (the ADT executable is located in the bin directory of the AIR SDK):
adt –certificate -cn SelfSigned 1024-RSA sampleCert.pfx samplePassword
ADT generates a keystore file named sampleCert.pfx containing a certificate and the related private key.
This example uses the minimum number of attributes that can be set for a certificate. You can use any values for the parameters in italics. The key type must be either 1024-RSA or 2048-RSA (see Digitally signing an AIR file).
Create the AIR installation file
From the command prompt, enter the following command (on a single line):
adt -package -storetype pkcs12 -keystore sampleCert.pfx HelloWorld.air HelloWorld-app.xml HelloWorld.html AIRAliases.js
You will be prompted for the keystore file password.
The HelloWorld.air argument is the AIR file that ADT produces. HelloWorld-app.xml is the application descriptor file. The subsequent arguments are the files used by your application. This example only uses two files, but you can include any number of files and directories.
After the AIR package is created, you can install and run the application by double-clicking the package file. You can also type the AIR filename as a command in a shell or command window.