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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Working with AIR native windows<br />

The scale mode for Flex and HTML windows is set to noScale automatically.<br />

Note: To determine the maximum and minimum window sizes allowed on the curr<strong>en</strong>t operating system, use the following<br />

static NativeWindow properties:<br />

var maxOSSize:Point = NativeWindow.systemMaxSize;<br />

var minOSSize:Point = NativeWindow.systemMinSize;<br />

Creating an HTML window<br />

Adobe AIR 1.0 and later<br />

To create an HTML window, you can either call the JavaScript Window.op<strong>en</strong>() method, or you can call the AIR<br />

HTMLLoader class createRootWindow() method.<br />

HTML cont<strong>en</strong>t in any security sandbox can use the standard JavaScript Window.op<strong>en</strong>() method. If the cont<strong>en</strong>t is<br />

running outside the application sandbox, the op<strong>en</strong>() method can only be called in response to user interaction, such<br />

as a mouse click or keypress. Wh<strong>en</strong> op<strong>en</strong>() is called, a window with system chrome is created to display the cont<strong>en</strong>t<br />

at the specified URL. For example:<br />

newWindow = window.op<strong>en</strong>("xmpl.html", "logWindow", "height=600, width=400, top=10, left=10");<br />

Note: You can ext<strong>en</strong>d the HTMLHost class in ActionScript to customize the window created with the JavaScript<br />

window.op<strong>en</strong>() function. See “About ext<strong>en</strong>ding the HTMLHost class” on page 1006.<br />

Cont<strong>en</strong>t in the application security sandbox has access to the more powerful method of creating windows,<br />

HTMLLoader.createRootWindow(). With this method, you can specify all the creation options for a new window. For<br />

example, the following JavaScript code creates a lightweight type window without system chrome that is 300x400<br />

pixels in size:<br />

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

options.systemChrome = "none";<br />

options.type = "lightweight";<br />

var windowBounds = new air.Rectangle(200,250,300,400);<br />

newHTMLLoader = air.HTMLLoader.createRootWindow(true, options, true, windowBounds);<br />

newHTMLLoader.load(new air.URLRequest("xmpl.html"));<br />

Note: If the cont<strong>en</strong>t loaded by a new window is outside the application security sandbox, the window object does not have<br />

the AIR properties: runtime, nativeWindow, or htmlLoader.<br />

If you create a transpar<strong>en</strong>t window, th<strong>en</strong> SWF cont<strong>en</strong>t embedded in the HTML loaded into that window is not always<br />

displayed. You must set the wmode parameter of the object or embed tag used to refer<strong>en</strong>ce the SWF file to either opaque<br />

or transpar<strong>en</strong>t. The default value of wmode is window, so, by default, SWF cont<strong>en</strong>t is not displayed in transpar<strong>en</strong>t<br />

windows. PDF cont<strong>en</strong>t cannot be displayed in transpar<strong>en</strong>t windows, no matter which wmode value is set. (Prior to AIR<br />

1.5.2, SWF cont<strong>en</strong>t could not be displayed in transpar<strong>en</strong>t windows, either.)<br />

Windows created with the createRootWindow() method remain indep<strong>en</strong>d<strong>en</strong>t from the op<strong>en</strong>ing window. The<br />

par<strong>en</strong>t and op<strong>en</strong>er properties of the JavaScript Window object are null. The op<strong>en</strong>ing window can access the<br />

Window object of the new window using the HTMLLoader refer<strong>en</strong>ce returned by the createRootWindow() function.<br />

In the context of the previous example, the statem<strong>en</strong>t newHTMLLoader.window would refer<strong>en</strong>ce the JavaScript<br />

Window object of the created window.<br />

Note: The createRootWindow() function can be called from both JavaScript and ActionScript.<br />

Last updated 6/6/2012<br />

900

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

Saved successfully!

Ooh no, something went wrong!