The following example shows how you can display web pages in an Adobe AIR HTML control by setting the location property.

Full code after the jump.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://airexamples.com/2009/01/03/displaying-web-pages-in-an-html-control-in-an-adobe-air-application/ -->
<mx:WindowedApplication name="HTML_location_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        width="1024"
        height="768">
 
    <mx:Script>
        <![CDATA[
            private function btn_click(evt:Event):void {
                html.location = textInput.text;
            }
        ]]>
    </mx:Script>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Form styleName="plain"
                defaultButton="{btn}"
                width="100%">
            <mx:FormItem label="location:"
                    direction="horizontal"
                    width="100%">
                <mx:TextInput id="textInput"
                        text="http://airexamples.com/"
                        width="100%" />
                <mx:Button id="btn"
                        label="Go"
                        click="btn_click(event);" />
            </mx:FormItem>
        </mx:Form>
    </mx:ApplicationControlBar>
 
    <mx:HTML id="html"
            width="100%"
            height="100%" />
 
</mx:WindowedApplication>
Tagged with:
 

4 Responses to Displaying web pages in an HTML control in an Adobe AIR application

  1. Gurpreet Singh says:

    Hi Peter,

    Thanks a ton for this example.

    I am new to AIR technology.
    I was looking to acheive this for long time.

    Can you guide me on two scenario?
    Scenario 1:
    I am developing an Air Project, wich will run on a corporate LAN.
    I want user to first login on corporate website before using air project.

    I am thinking of two options:
    a) When user open air project ask user to click on a button to login on corporate site, when user click the button launch the corporate site’s login page and close the air application after login user will be taken to a web page which will say click here to launch air application, there i can pass the user session info as arguments to the air application while launching.
    b) I open the corporate site’s login page inside air application using above logic, but in that case, after user logs in what best can i do to close the web page and pass on the session info to air application?

    Scenario 2:
    As in flex project we can create multiple applications (multiple swf files) and switch from one application to another using navigateToURL. How can we switch from one swf to another in an air project?

    Thanks & Regards,
    Gurpreet Singh

  2. shirak says:

    Hello,
    Why AIR application is failing when I try to connect to https website.

  3. Israel says:

    how could i get Air to print out the html in the Html control?

  4. Anand Meena says:

    Hi Peter,

    I am new in This technology.

    Is it possible that I Open my gmail account through HTML control of Adobe Air?

    If I enter my email address and password in 2 textboxes and than click on a button, It automatic redirect to my gmail account.
    Is this possible?

    Thanks in advance.

    Anand Meena

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam Protection by WP-SpamFree