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

Scripting the AIR HTML Container<br />

About ext<strong>en</strong>ding the HTMLHost class<br />

Adobe AIR 1.0 and later<br />

If, for example, your application pres<strong>en</strong>ts multiple HTMLLoader objects in a tabbed interface, you may want title<br />

changes made by the loaded HTML pages to change the label of the tab, not the title of the main window. Similarly,<br />

your code could respond to a window.moveTo() call by repositioning the HTMLLoader object in its par<strong>en</strong>t display<br />

object container, by moving the window that contains the HTMLLoader object, by doing nothing at all, or by doing<br />

something else <strong>en</strong>tirely.<br />

The AIR HTMLHost class controls the following JavaScript properties and methods:<br />

window.status<br />

window.docum<strong>en</strong>t.title<br />

window.location<br />

window.blur()<br />

window.close()<br />

window.focus()<br />

window.moveBy()<br />

window.moveTo()<br />

window.op<strong>en</strong>()<br />

window.resizeBy()<br />

window.resizeTo()<br />

Wh<strong>en</strong> you create an HTMLLoader object using new HTMLLoader(), the listed JavaScript properties or methods are<br />

not <strong>en</strong>abled. The HTMLHost class provides a default, browser-like implem<strong>en</strong>tation of these JavaScript APIs. You can<br />

also ext<strong>en</strong>d the HTMLHost class to customize the behavior. To create an HTMLHost object supporting the default<br />

behavior, set the defaultBehaviors parameter to true in the HTMLHost constructor:<br />

var defaultHost:HTMLHost = new HTMLHost(true);<br />

Wh<strong>en</strong> you create an HTML window in AIR with the HTMLLoader class createRootWindow() method, an<br />

HTMLHost instance supporting the default behaviors is assigned automatically. You can change the host object<br />

behavior by assigning a differ<strong>en</strong>t HTMLHost implem<strong>en</strong>tation to the htmlHost property of the HTMLLoader, or you<br />

can assign null to disable the features <strong>en</strong>tirely.<br />

Note: AIR assigns a default HTMLHost object to the initial window created for an HTML-based AIR application and<br />

any windows created by the default implem<strong>en</strong>tation of the JavaScript window.op<strong>en</strong>() method.<br />

Example: Ext<strong>en</strong>ding the HTMLHost class<br />

Adobe AIR 1.0 and later<br />

The following example shows how to customize the way that an HTMLLoader object affects the user interface, by<br />

ext<strong>en</strong>ding the HTMLHost class:<br />

Flex example:<br />

1 Create a class that ext<strong>en</strong>ds the HTMLHost class (a subclass).<br />

Last updated 6/6/2012<br />

1006

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

Saved successfully!

Ooh no, something went wrong!