Sunday, June 14, 2009

Simple HTML Browser in AIR

A Simple HTML Browser in AIR, with the History support.

Handling of AIR's HTML Component is simple...

location = myurl jumps to a page,

historyBack()returns to the previous page

historyForward()goes to the next page

Download the AIR file

SourceCode For HTML Browser

<?xml version="1.0" encoding="utf-8"?>
    layout="vertical" width="600" height="500"
    backgroundColor="0x000000" backgroundAlpha="0.5"

[Bindable]private var hisArr:Array = new Array();
private function setHistory():void{
    hisArr = new Array();
    var len:int = myHTML.historyLength;
    while( len -- ){
        hisArr[len] = myHTML.getHistoryAt(len);

<mx:HBox width="100%">
    <mx:TextInput id="myURL" text=""
        enter="{myHTML.location = myURL.text;}"/>   
        <mx:Button label="GO!" click="{ myHTML.location = myURL.text; }"/>
        <mx:Button label="Back" click="{ myHTML.historyBack() }"/>
        <mx:Button label="Forward" click="{ myHTML.historyForward() }"/>

<mx:HBox width="100%" height="100%">
    <mx:DataGrid id="dg" dataProvider="{hisArr}" width="100" height="100%"
        itemClick="{myHTML.historyPosition = dg.selectedIndex}">
            <mx:DataGridColumn headerText="Title" dataField="title"/>
            <mx:DataGridColumn headerText="URL" dataField="url" visible="false"/>
    <mx:HTML id="myHTML" width="100%" height="100%" complete="setHistory()"/>   


1 comment:

Benjamin said...

That's nice but, what if the webpage url is written by flex or swfaddress ?

How can we notify the AIR HTML component and update the address bar ?