For a quick, hands-on illustration of how Adobe® AIR™ works, use these instructions to create and package a simple SWF file-based AIR "Hello World" application using Adobe Flex Builder 3.
If you haven't already done so, download and install Flex Builder 3. For more information, see Setting up the Flex 3 SDK.
Flex Builder 3 includes the tools you need to develop and package AIR applications. You begin to create AIR applications in Flex Builder in the same way that you create other Flex-based application projects, by defining a new project.
Create the project in Flex Builder
AIR projects initially consist of two files: the main MXML file and an application XML file (referred to as the application descriptor file). The latter file specifies parameters for identifying, installing, and launching AIR applications. There will be occasions when you will want to manually edit this file. For now, be aware that it exists.
To write the "Hello World" application code, you edit the application MXML file (AIRHelloWorld.mxml), which is open in the editor. If it isn't, use the Project Navigator to open the file.
Flex AIR applications are contained within the MXML WindowedApplication tag. The MXML WindowedApplication tag creates a simple window that includes basic window controls such as a title bar and close button.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" title="Hello World">
</mx:WindowedApplication>
<?xml version="1.0" encoding="utf-8"?><?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" title="Hello World">
<mx:Label text="Hello AIR" horizontalCenter="0" verticalCenter="0"/>
</mx:WindowedApplication>
<mx:Style>
WindowedApplication
{
background-color:"0x999999";
background-alpha:"0.5";
}
</mx:Style>
These style settings apply to the entire application and render the window background a slightly transparent gray.
The application code now looks like the following:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" title="Hello World">
<mx:Style>
WIndowedApplication
{
background-color:"0x999999";
background-alpha:"0.5";
}
</mx:Style>
<mx:Label text="Hello AIR" horizontalCenter="0" verticalCenter="0"/>
</mx:WindowedApplication>
To test the application code that you've written, run it in debug mode.
You can also select the Run > Debug > AIRHelloWorld command.
The resulting AIR application should look like the following example (the green background is the desktop):
You are now ready to use Flex Builder to package the "Hello World" application into an AIR file for distribution. An AIR file is an archive file that contains the application files, which are all of the files contained in the project's bin folder. In this simple example, those files are the SWF and application XML files. You distribute the AIR package to users who then use it to install the application. A required step in this process is to digitally sign it.
You can now run the application from the Project Navigator in Flex Builder or from the file system by double-clicking the AIR file.