Native Windows

The root tag of any AIR application is <mx:WindowedApplication>, which is all it takes to make the application look like a native window of the OS where it runs. For example, install and run the same HelloWorld.air application on Mac OS, and, instead of looking like Figure 9-2, the window looks like Figure 9-6.

You can have only one <mx:WindowedApplication> tag per application, however. If you need to instantiate other windows, you need to use the <mx:Window> component. With it, you can specify multiple windows that may or may not look like a native window based on the chrome you specify. The Window class contains an important property called nativeWindow of type flash.display.NativeWindow, which is the class you would use to create new windows if you were developing a plain Flash (no Flex) application.

HelloWorld on MAC OS

Figure 9-6. HelloWorld on MAC OS

If you need to open a new native window, create a custom component called HelloWindow with <mx:Window> as the root tag:

<?xml version="1.0" encoding="utf-8"?>
<mx:Window xmlns:mx="http://www.adobe.com/2006/mxml"
              layout="absolute" width="400" height="300">
   <mx:Button label="Close me" click="close()"/>
</mx:Window>

The following application instantiates and opens this native window:

<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:Label text="Hello World" /> <mx:Button ...

Get Agile Enterprise Application Development with Flex 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.