| Pacote | flash.html |
| Classe | public class HTMLHost |
| Herança | HTMLHost Object |
window object of
the HTML page. These methods and properties are the following:
window.blur()window.focus()window.moveBy()window.moveTo()window.locationwindow.close()window.open()window.resizeBy()window.resizeTo()window.statuswindow.document.titleThe methods in this class provide ways of handles changes in each of these window
settings. To use this class, create a new class that extends the HTMLHost class (a subclass) and
override the methods for which you want to define behaviors. The methods of the HTMLHost class
handle JavaScript properties and methods as follows:
| JavaScript property or method | HTMLHost method |
|---|---|
window.blur() | windowBlur() |
window.focus() | windowFocus |
window.location | updateLocation |
window.close() | windowClose |
window.open() | createWindow |
window.status | updateStatus |
window.document.title | updateTitle |
To respond to changes in window.moveBy(), window.moveTo(),
window.resizeBy(), and window.resizeTo() methods, override
the set windowRect() method in the subclass of HTMLHost.
Each HTMLHost object can be associated with at most one HTMLLoader object. Assigning
an HTMLHost instance to the htmlHost property of the HTMLLoader object
establishes this relationship. Assigning null to the htmlHost
property of the HTMLLoader object or setting the HTMLHost object as the htmlHost
property of another HTMLLoader object removes the HTMLHost from the first HTMLLoader object.
Veja também
| Propriedade | Definido por | ||
|---|---|---|---|
![]() | constructor : Object
A reference to the class object or constructor function for a given object instance.
| Object | |
| htmlLoader : HTMLLoader
[read-only]
The HTMLLoader object to which this HostControl object applies.
| HTMLHost | ||
![]() | prototype : Object
[static]
A reference to the prototype object of a class or function object.
| Object | |
| windowRect : Rectangle
The property that is changed when JavaScript code in the HTMLLoader calls the
window.moveBy() method, the window.moveTo(),
window.resizeBy() method, or the window.resizeTo() method.
| HTMLHost | ||
| Método | Definido por | ||
|---|---|---|---|
|
Creates an HTMLHost object.
| HTMLHost | ||
|
The function called when JavaScript code in the HTMLLoader calls the
window.open() method.
| HTMLHost | ||
![]() |
Indicates whether an object has a specified property defined.
| Object | |
![]() |
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter.
| Object | |
![]() |
Indicates whether the specified property exists and is enumerable.
| Object | |
![]() |
Sets the availability of a dynamic property for loop operations.
| Object | |
![]() |
Returns the string representation of the specified object.
| Object | |
|
The function called when JavaScript code in the HTMLLoader sets the
window.location property.
| HTMLHost | ||
|
The function called when JavaScript code in the HTMLLoader sets the
window.status property.
| HTMLHost | ||
|
The function called when JavaScript code in the HTMLLoader sets the
window.document.title property or when the title
element changes, either via the DOM or because of a new page load.
| HTMLHost | ||
![]() |
Returns the primitive value of the specified object.
| Object | |
|
The function called when JavaScript code in the HTMLLoader calls the
window.blur() method.
| HTMLHost | ||
|
The function called when JavaScript code in the HTMLLoader calls the
window.close() method.
| HTMLHost | ||
|
The function called when JavaScript code in the HTMLLoader calls the
window.focus() method.
| HTMLHost | ||
| htmlLoader | propriedade |
htmlLoader:HTMLLoader [read-only]
The HTMLLoader object to which this HostControl object applies. The htmlHost
property of that HTMLLoader object is set to this HostControl object.
public function get htmlLoader():HTMLLoader
Veja também
| windowRect | propriedade |
windowRect:Rectangle [read-write]
The property that is changed when JavaScript code in the HTMLLoader calls the
window.moveBy() method, the window.moveTo(),
window.resizeBy() method, or the window.resizeTo() method.
In the subclass of HTMLHost, override the set windowRect() method
to handle the new window bounds, as desired.
public function get windowRect():Rectangle
public function set windowRect(value:Rectangle):void
| HTMLHost | () | Construtor |
public function HTMLHost(defaultBehaviors:Boolean = true)
Creates an HTMLHost object.
ParâmetrosdefaultBehaviors:Boolean (default = true) — Whether root-content behaviors should be provided by default.
|
| createWindow | () | método |
public function createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader
The function called when JavaScript code in the HTMLLoader calls the
window.open() method.
By default, a JavaScript call to window.open() in the HTML
page of an HTMLLoader does not open an new NativeWindow object in the
runtime. You can do so when overriding the createWindow method in
a subclass of the HTMLHost class.
Parâmetros
windowCreateOptions:HTMLWindowCreateOptions — An object containing properties in the string passed as the
features parameter of the call to window.open().
|
HTMLLoader — An HTMLLoader object that will contain the new HTML page. Typically,
you create a new HTMLLoader object in this method, add it to the stage of a new
NativeWindow object, and then return it.
|
| updateLocation | () | método |
public function updateLocation(locationURL:String):void
The function called when JavaScript code in the HTMLLoader sets the
window.location property.
Parâmetros
locationURL:String — The value that the location property
of the window property of the HTMLLoader is set to.
|
| updateStatus | () | método |
public function updateStatus(status:String):void
The function called when JavaScript code in the HTMLLoader sets the
window.status property.
Parâmetros
status:String — The value that the status property
of the window property of the HTMLLoader is set to.
|
| updateTitle | () | método |
public function updateTitle(title:String):void
The function called when JavaScript code in the HTMLLoader sets the
window.document.title property or when the title
element changes, either via the DOM or because of a new page load.
Parâmetros
title:String — The value that the window.document,title property
of the HTMLLoader is set to.
|
| windowBlur | () | método |
public function windowBlur():void
The function called when JavaScript code in the HTMLLoader calls the
window.blur() method.
| windowClose | () | método |
public function windowClose():void
The function called when JavaScript code in the HTMLLoader calls the
window.close() method.
By default, a JavaScript call to window.close() in the HTML
page of an HTMLLoader will close the windows containing the HTMLLoader.
| windowFocus | () | método |
public function windowFocus():void
The function called when JavaScript code in the HTMLLoader calls the
window.focus() method.
window
object:
package
{
import flash.html.HTMLHost;
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.StageScaleMode;
import flash.geom.Rectangle;
import flash.text.TextField;
public class CustomHost extends HTMLHost
{
import flash.html.*;
public var statusField:TextField;
public function CustomHost(defaultBehaviors:Boolean=true)
{
super(defaultBehaviors);
}
override public function windowClose():void
{
htmlLoader.stage.window.close();
}
override public function createWindow(windowCreateOptions:HTMLWindowCreateOptions):HTMLLoader
{
var initOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
var window:NativeWindow = new NativeWindow(true, initOptions);
htmlLoader.width = window.width;
htmlLoader.height = window.height;
window.stage.scaleMode = StageScaleMode.NO_SCALE;
window.stage.addChild(htmlLoader);
return htmlLoader;
}
override public function updateLocation(locationURL:String):void
{
trace(locationURL);
}
override public function set windowRect(value:Rectangle):void
{
htmlLoader.stage.window.bounds = value;
}
override public function updateStatus(status:String):void
{
statusField.text = status;
}
override public function updateTitle(title:String):void
{
htmlLoader.stage.window.title = title + "- Example Application";
}
override public function windowBlur():void
{
htmlLoader.alpha = 0.5;
}
override public function windowFocus():void
{
htmlLoader.alpha = 1;
}
}
}statusBar. The HTMLLoader
object defines a CustomHost object as its htmlHost property:
package
{
import flash.display.Sprite;
public class SimpleHTMLBox extends Sprite
{
import mx.controls.HTML;
import flash.html.HTMLLoader;
import flash.text.TextField;
import flash.net.URLRequest;
import CustomHost;
private var host:CustomHost;
private var statusField:TextField;
private var html:HTMLLoader;
public function SimpleHTMLBox()
{
html = new HTMLLoader();
var url:String = "Test.html";
var urlReq:URLRequest = new URLRequest(url);
html.load(urlReq);
host = new CustomHost();
html.htmlHost = host;
statusField = new TextField();
host.statusField = statusField;
configureUI();
}
private function configureUI():void
{
html.width = 400;
html.height = 200;
statusField.width = 400;
statusField.height = 24;
statusField.border = true;
statusField.y = 200;
addChild(html);
addChild(statusField);
}
}
}Build an AIR application that adds an object defined by this class to the main window's stage.
Create an HTML page named Test.html in the application resources directory (the directory that contains the application descriptor file), and add the following content in it:
<html>
<head>
<title>Test</title>
</head>
<body>
<a href="#" onclick="window.open('Test.html')">window.open('Test.html')</a>
<br/><a href="#" onclick="window.document.location = 'www.adobe.com'">window.document.location = 'www.adobe.com'</a>
<br/><a href="#" onclick="window.moveBy(6, 12)">moveBy(6, 12)</a>
<br/><a href="#" onclick="window.close()">window.close()</a>
<br/><a href="#" onclick="window.blur()">window.blur()</a>
<br/><a href="#" onclick="window.focus()">window.focus()</a>
<br/><a href="#" onclick="window.status = new Date().toString()">window.status = new Date().toString()</a>
</body>
</html>When you test the application, the CustomHost class handles the user-interface related JavaScript settings in the HTML page.