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>
{ 4 comments… read them below or add one }
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
Hello,
Why AIR application is failing when I try to connect to https website.
how could i get Air to print out the html in the Html control?
thanks for this post. it helps us in our project.