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

Windows in AIR<br />

Adobe AIR 1.0 and later<br />

AIR supports three distinct APIs for working with windows:<br />

The ActionScript-ori<strong>en</strong>ted NativeWindow class provides the lowest level window API. Use NativeWindows in<br />

ActionScript and Flash Professional-authored applications. Consider ext<strong>en</strong>ding the NativeWindow class to<br />

specialize the windows used in your application.<br />

In the HTML <strong>en</strong>vironm<strong>en</strong>t, you can use the JavaScript Window class, just as you would in a browser-based web<br />

application. Calls to JavaScript Window methods are forwarded to the underlying native window object.<br />

The Flex framework mx:WindowedApplication and mx:Window classes provide a Flex “wrapper” for the<br />

NativeWindow class. The WindowedApplication compon<strong>en</strong>t replaces the Application compon<strong>en</strong>t wh<strong>en</strong> you create<br />

an AIR application with Flex and must always be used as the initial window in your Flex application.<br />

ActionScript windows<br />

Wh<strong>en</strong> you create windows with the NativeWindow class, use the Flash Player stage and display list directly. To add a<br />

visual object to a NativeWindow, add the object to the display list of the window stage or to another display object<br />

container on the stage.<br />

HTML windows<br />

Wh<strong>en</strong> you create HTML windows, you use HTML, CSS, and JavaScript to display cont<strong>en</strong>t. To add a visual object to an<br />

HTML window, you add that cont<strong>en</strong>t to the HTML DOM. HTML windows are a special category of NativeWindow.<br />

The AIR host defines a nativeWindow property in HTML windows that provides access to the underlying<br />

NativeWindow instance. You can use this property to access the NativeWindow properties, methods, and ev<strong>en</strong>ts<br />

described here.<br />

Note: The JavaScript Window object also has methods for scripting the containing window, such as moveTo() and<br />

close(). Where overlapping methods are available, you can use whichever method that is conv<strong>en</strong>i<strong>en</strong>t.<br />

Flex Framework windows<br />

Wh<strong>en</strong> you create windows with the Flex framework, you typically use MXML compon<strong>en</strong>ts to populate the window.<br />

To add a Flex compon<strong>en</strong>t to a window, you add the compon<strong>en</strong>t elem<strong>en</strong>t to the window MXML definition. You can<br />

also use ActionScript to add cont<strong>en</strong>t dynamically. The mx:WindowedApplication and mx:Window compon<strong>en</strong>ts are<br />

designed as Flex containers and so can accept Flex compon<strong>en</strong>ts directly, whereas NativeWindow objects cannot. Wh<strong>en</strong><br />

necessary, the NativeWindow properties and methods can be accessed through the WindowedApplication and<br />

Window objects using the nativeWindow property.<br />

The initial application window<br />

The first window of your application is automatically created for you by AIR. AIR sets the properties and cont<strong>en</strong>t of<br />

the window using the parameters specified in the initialWindow elem<strong>en</strong>t of the application descriptor file.<br />

If the root cont<strong>en</strong>t is a SWF file, AIR creates a NativeWindow instance, loads the SWF file, and adds it to the window<br />

stage. If the root cont<strong>en</strong>t is an HTML file, AIR creates an HTML window and loads the HTML.<br />

Native window classes<br />

Adobe AIR 1.0 and later<br />

The native window API contains the following classes:<br />

Last updated 6/6/2012<br />

890

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

Saved successfully!

Ooh no, something went wrong!