Chapter 9. Flex on AIR

Adobe’s AIR runtime is your ticket to the world of cross-platform desktop application development. And the great news is that you can use the tools you already know. AIR supports building desktop applications in either Flex or DHTML. In this chapter, I’ll concentrate on the use of Flex.

Creating an AIR Version of the Runner’s Calculator

The process starts with creating an AIR project in Flex Builder. Use the New→Project menu item as you normally would. Then select “Desktop application” instead of “Web application”, as I have done in Figure 9-1.

The Project dialog with AIR selected
Figure 9-1. The Project dialog with AIR selected

I’m going to create an AIR version of the runner’s calculator example from Chapter 3. Once I’ve created the AIR project using the New MXML Project command, I copy all of the content from my original runner application, except for the mx:Application tag, into the AIR_runner.mxml file. This is shown in Example 9-1.

Example 9-1. AIR_runner.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com
  /2006/mxml”
layout="horizontal”
 creationComplete="onMilesChange(event)"> <mx:Script> <![CDATA[ private function onMilesChange( event:Event ) : void { var miles:Number = parseFloat( txtMiles.text ); var mile:Number = 1.0; var weeks:int = 0; var weekData:Array = []; while( mile < miles ) { weeks += 1; weekData.push( { week: weeks, miles: Math.round ...

Get Getting Started with Flex 3 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.