O'Reilly logo

Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime by Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

15.3. Navigating History

Now that you have seen how to use the location property of the HTML component, it would be useful if we could give users the option to move forward or backward throughout their browser history. Fortunately, the HTML component makes this pretty simple. In this section, we will build a basic Web browser with current location as well as forward and back history controls. To get started, create a new AIR project named Chapter15_Browser, which will also create a new file named Chapter15_Browser.mxml. Next, add the contents of Listing 15-3 to the Chapter15_Browser.mxml file.

Listing 15-3 is the base of the browser example with additional functionality to be added within this section. There is a TextInput component that has its text property bound to the location property of the HTML component property. The TextInput component allows the user to type in a URL and then click [Enter], which calls the goToURL() function. The goToURL() function sets the HTML component's location property to the text value of the TextInput component. The Go! button will also call the goToURL() function when clicked. Running the application will result in something similar to Figure 15-3.

Example 15-3. The base of the browser example
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute" width="800" height="600">

    <mx:Script>
        <![CDATA[
        private function goToURL():void{ html.location=loc.text; } ]]> </mx:Script> <mx:TextInput ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required