Determining when the location changes on the HTML control in Adobe AIR
In a previous example, “Displaying web pages in an HTML control in an Adobe AIR application”, we saw how you can display web pages in an Adobe AIR HTML control by setting the location
property.
The following example shows how you can determine when the Adobe AIR HTML control’s location changes using the locationChange
event.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?> <!-- http://airexamples.com/2009/01/03/determining-when-the-location-changes-on-the-html-control-in-adobe-air/ --> <mx:WindowedApplication name="HTML_locationChange_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="white" width="1024" height="768"> <mx:Script> <![CDATA[ import mx.controls.Alert; private function btn_click(evt:Event):void { html.location = textInput.text; } private function html_locationChange(evt:Event):void { Alert.show("Attempting to load " + html.location); } ]]> </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%" locationChange="html_locationChange(event)" /> </mx:WindowedApplication>
- http://get.adobe.com/air/
- Platform ActionScript Language Reference
Recent Posts
- Detecting the number of screens on a users system in Adobe AIR
- Opening a new NativeWindow in Adobe AIR
- Detecting the line-ending character sequence used by the host operating system in Adobe AIR
- Displaying a custom title bar icon in a WindowedApplication container in Adobe AIR
- Setting a custom text style on the status bar on a WindowedApplication container in Adobe AIR
- Keeping a WindowedApplication on top of other windows in Adobe AIR
- Specifying whether a new Window is focused in Adobe AIR
- Opening a new Window in Adobe AIR
- Setting the file size display mode in the Flex FileSystemDataGrid control in Adobe AIR
- Sorting the FileSystemDataGrid control by date in Adobe AIR
Archives
- March 2010 (10)
- February 2009 (3)
- January 2009 (6)
- December 2008 (44)