Avg. Rating 3.7

Problem

This is a simple recipe to illustrate how powerful the core HTML functionality is in AIR. You will see how to build a simple web browser in 5 lines of code.

Solution

The Adobe AIR runtime uses the Webkit HTML engine. As such, most of the complexity of using HTML in your applications is hidden. This simple demo loads up a webpage that has CSS and Ajax to demonstrate the capabilities. Also load a foreign page like http://www.yahoo.jp to see how Kanji characters are handled.

Detailed explanation

Here is the source code:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
    <mx:Label text="Please enter your URL and hit &quot;enter&quot;" />
    <mx:TextInput id="URLtext" width="100%" enter="HTML.location=URLtext.text" />
    <mx:HTML id="HTML" location="http://www.google.com/ig" width="100%" />   
</mx:WindowedApplication>

Yep - that's really it ;-)

I have attached a project with the source and also added some extra stub code in case you want to experiment with building a home, history, and back functionality into your browser project.

AIR3_Browser.zip
[HTML Browser, built for Flex Builder 3, beta 3]
Picture 21.jpg

+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes