O'Reilly logo

Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime by Rich Tretola

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

9.1. Creating Windows

Creating windows with AIR is an extremely simple process. There are two different types of AIR application windows. The NativeWindow is a lightweight window class that falls under the flash class path and can only add children that are under the flash class path. The mx:Window component is a full window component that falls under the mx namespace and therefore can include any component under the mx namespace.

9.1.1. NativeWindow

Since NativeWindow falls under the flash.display package, it can be used in any Flex, Flash, or HTML AIR project. NativeWindows have many properties that can alter their functionality and look. The following example will create a basic NativeWindow and build on the same file, creating different versions of the NativeWindow.

Start by creating a new AIR project named Chapter9_NW, which will create a new application file named Chapter9_NW.mxml. This will look like Listing 9-1.

Example 9-1. The newly created Chapter9_NW.mxml file
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
</mx:WindowedApplication>

Now add a new script block by adding the code from Listing 9-2. This function will create a default new NativeWindow object by passing a new NativeWindowInitOptions() object into the constructor. Next the title, width, and height are set. A new TextField is created and added to the NativeWindow by calling the stage.addChild() method. The contents of the NativeWindow ...

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