13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with AIR native windows<br />

import flash.display.NativeWindow;<br />

var mainWindow:NativeWindow = this.stage.nativeWindow;<br />

mainWindow.maximize();<br />

mainWindow.activate();<br />

Creating the initial window with Flex<br />

Adobe AIR 1.0 and later<br />

Wh<strong>en</strong> creating an AIR application with the Flex framework, use the mx:WindowedApplication as the root elem<strong>en</strong>t of<br />

your main MXML file. (You can use the mx:Application compon<strong>en</strong>t, but it does not support all the features available<br />

in AIR.) The WindowedApplication compon<strong>en</strong>t serves as the initial <strong>en</strong>try point for the application.<br />

Wh<strong>en</strong> you launch the application, AIR creates a native window, initializes the Flex framework, and adds the<br />

WindowedApplication object to the window stage. Wh<strong>en</strong> the launch sequ<strong>en</strong>ce finishes, the WindowedApplication<br />

dispatches an applicationComplete ev<strong>en</strong>t. Access the desktop window object with the nativeWindow property of<br />

the WindowedApplication instance.<br />

The following example creates a simple WindowedApplication compon<strong>en</strong>t that sets its x and y coordinates:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Creating a NativeWindow<br />

Adobe AIR 1.0 and later<br />

To create a NativeWindow, pass a NativeWindowInitOptions object to the NativeWindow constructor:<br />

var options:NativeWindowInitOptions = new NativeWindowInitOptions();<br />

options.systemChrome = NativeWindowSystemChrome.STANDARD;<br />

options.transpar<strong>en</strong>t = false;<br />

var newWindow:NativeWindow = new NativeWindow(options);<br />

The window is not shown until you set the visible property to true or call the activate() method.<br />

Once the window is created, you can initialize its properties and load cont<strong>en</strong>t into the window using the stage property<br />

and Flash display list techniques.<br />

In almost all cases, you should set the stage scaleMode property of a new native window to noScale (use the<br />

StageScaleMode.NO_SCALE constant). The Flash scale modes are designed for situations in which the application<br />

author does not know the aspect ratio of the application display space in advance. The scale modes let the author<br />

choose the least-bad compromise: clip the cont<strong>en</strong>t, stretch or squash it, or pad it with empty space. Since you control<br />

the display space in AIR (the window frame), you can size the window to the cont<strong>en</strong>t or the cont<strong>en</strong>t to the window<br />

without compromise.<br />

Last updated 6/6/2012<br />

899

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!