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

Scripting the AIR HTML Container<br />

2 Override methods of the new class to handle changes in the user interface-related settings. For example, the<br />

following class, CustomHost, defines behaviors for calls to window.op<strong>en</strong>() and changes to<br />

window.docum<strong>en</strong>t.title. Calls to window.op<strong>en</strong>() op<strong>en</strong> the HTML page in a new window, and changes to<br />

window.docum<strong>en</strong>t.title (including the setting of the elem<strong>en</strong>t of an HTML page) set the title of that<br />

window.<br />

package<br />

{<br />

import flash.html.*;<br />

import flash.display.StageScaleMode;<br />

import flash.display.NativeWindow;<br />

import flash.display.NativeWindowInitOptions;<br />

}<br />

public class CustomHost ext<strong>en</strong>ds HTMLHost<br />

{<br />

import flash.html.*;<br />

override public function<br />

createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader<br />

{<br />

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

var bounds:Rectangle = new Rectangle(windowCreateOptions.x,<br />

windowCreateOptions.y,<br />

windowCreateOptions.width,<br />

windowCreateOptions.height);<br />

var htmlControl:HTMLLoader = HTMLLoader.createRootWindow(true, initOptions,<br />

windowCreateOptions.scrollBarsVisible, bounds);<br />

htmlControl.htmlHost = new HTMLHostImplem<strong>en</strong>tation();<br />

if(windowCreateOptions.fullscre<strong>en</strong>){<br />

htmlControl.stage.displayState =<br />

StageDisplayState.FULL_SCREEN_INTERACTIVE;<br />

}<br />

return htmlControl;<br />

}<br />

override public function updateTitle(title:String):void<br />

{<br />

htmlLoader.stage.nativeWindow.title = title;<br />

}<br />

}<br />

3 In the code that contains the HTMLLoader (not the code of the new subclass of HTMLHost), create an object of<br />

the new class. Assign the new object to the htmlHost property of the HTMLLoader. The following Flex code uses<br />

the CustomHost class defined in the previous step:<br />

Last updated 6/6/2012<br />

1007

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

Saved successfully!

Ooh no, something went wrong!