5.1. Create Your First AIR Flex Application

Flex-based AIR applications may consist of MXML code, ActionScript code, or both. Since Flex-based AIR applications consist of source code that can be edited with any basic text editor, Flex Builder 3 is not necessary to write the application code. Although you may write the source code with an editor as simple as Notepad or TextEdit, you will still need a compiler to test the application. Flex Builder 3 makes testing very easy. The following examples demonstrate how to test AIR applications using Flex Builder and the AIR SDK.

5.1.1. Testing with Flex Builder

Open Flex Builder and create a new AIR project called HelloWorld. Please review Chapter 3 for information on creating AIR projects within Flex Builder. Once you have created this project, you should see a navigator window that resembles Figure 5-1.

Figure 5-1. The HelloWorld AIR project in Flex Builder 3.

Update the new HelloWorld.mxml file so that the code looks like Listing 5-1.

Example 5-1. HelloWorld.mxml sample code
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
      xmlns:mx="http://www.adobe.com/2006/mxml"
      layout="absolute">
      <mx:Label text="Hello World!"
              horizontalCenter="0"
              verticalCenter="0"/>
</mx:WindowedApplication>

To test this project with Flex Builder, you will simply need to click the green Play button in the top toolbar. Flex Builder will launch a ...

Get Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.