stageWebView in actionScript 3 (

27 May

The StageWebView class displays HTML content in a stage view port.

The StageWebView class provides a simple means to display HTML content on devices where the HTMLLoader class is not supported. The class provides no interaction between ActionScript and the HTML content except through the methods and properties of the StageWebView class itself. There is, for example, no way to pass values or call functions between ActionScript and JavaScript.

AIR profile support: This feature is supported on all desktop operating systems and mobile devices, but is not supported on AIR for TV devices. You can test for support at run time using the StageWebView.isSupported property. See AIR Profile Support for more information regarding API support across multiple profiles.

On devices in the mobile and extended mobile profiles, the StageWebView class uses the system web control provided by the device operating system. Thus, the available features and rendering appearance may vary from device to device. On desktop computers (in the desktop and extended desktop profiles), the StageWebView class uses the internal AIR WebKit engine. The features available and rendering appearance are the same as those of the HTMLLoader class (without the close integration and script bridging between ActionScript and JavaScript provided by an HTMLLoader instance). Test the isSupported property of the StageWebView class to determine whether the class is supported on the current device.

The StageWebView class is NOT a display object and cannot be added to the Flash display list. Instead you display a StageWebView object by attaching it directly to a stage using the stage property. The StageWebView instance attached to a stage is displayed on top of any Flash display objects. You control the size and position of the rendering area with the viewPort property. There is no way to control the depth ordering of different StageWebView objects. Overlapping two instances is not recommended.

When the content within the StageWebView object has focus, the StageWebView object has the first opportunity to handle keyboard input. The stage to which the StageWebView object is attached dispatches any keyboard input that is not handled. The normal event capture/bubble cycle does not apply here since the StageWebView instance is not part of the display list.


package  {
    import flash.display.MovieClip;
    import flash.geom.Rectangle;
    import flash.ui.Keyboard;
    import flash.desktop.NativeApplication;

    public class StageWebViewExample extends MovieClip{

        private var webView:StageWebView = new StageWebView();

        public function StageWebViewExample()
            webView.stage = this.stage;
            webView.viewPort = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight );
            webView.loadURL( "" );

            stage.addEventListener( KeyboardEvent.KEY_DOWN, onKey );

        private function onKey( event:KeyboardEvent ):void
            if( event.keyCode == Keyboard.BACK && webView.isHistoryBackEnabled )

            if( event.keyCode == Keyboard.SEARCH && webView.isHistoryForwardEnabled )

Original Link


2 responses to “stageWebView in actionScript 3 (

  1. Mikale

    August 24, 2011 at 8:02 am

    Question: What version of the AIR SDK does the example code use? I tried it in Flash CS5 with AIR 2.5 and it said the StageWebView was an undefined method.

    And, does StageWebView finally work on the iPhone now?

    • flashpri

      August 25, 2011 at 12:05 am

      Answer: I am using Flash CS5.5 and Adobe Air for iOS. It will work in iPhone.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: