An HTML control displays HTML web pages in your application. It is designed to be used to render specific external HTML content within your AIR application. It offers functionality like a lightweight web browser, including loading HTML pages, navigation history, and the ability to access the raw HTML content. The HTML control is not designed or intended to be used as a replacement for the Text or TextArea controls. Those controls are more appropriate for displaying formatted text or for use as an item renderer for displaying short runs of text.
You use the <mx:HTML> tag to define an HTML control in MXML, as the following example shows. Specify an id value if you intend to refer to a component elsewhere in your MXML, either in another tag or in an ActionScript block.
You specify the location of the HTML page to display by setting the location property.
The following example demonstrates the use of an HTML control in a simple application. The HTML control's location property is set to "http://labs.adobe.com/", so that URL is opened in the control when it loads. In addition, when the "back" and "forward" are clicked they call the control's historyBack() and historyForward() methods. A TextInput control allows the user to enter a URL location. When a third "go" button is clicked, the HTML control's location property is set to the text property of the input text field.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:ControlBar width="100%">
<mx:Button label="< Back" click="content.historyBack();"/>
<mx:Button label="Forward >" click="content.historyForward();"/>
<mx:TextInput id="address" text="{content.location}" width="100%"/>
<mx:Button label="Go!" click="content.location = address.text"/>
</mx:ControlBar>
<mx:Canvas width="100%" height="100%">
<mx:HTML id="content" location="http://labs.adobe.com/"/>
</mx:Canvas>
</mx:WindowedApplication>
For a user interacting with an HTML control, the experience is like using a web browser with only the content window and no menu bar or navigation buttons. The HTML page content displays in the control. The user can interact with the content through form fields and buttons and by clicking hyperlinks. Some of these interactions, such as clicking a link or submitting a form, would normally cause a browser to load a new page. These actions cause the HTML control to display the content of the new page and also change the value of the control's location property.