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