O'Reilly logo

Getting Started with Flex 3 by Emily Kim, Jack D. Herrington

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required