StageWebViewBridge is an extended version of flash.media.StageWebView, which is a class to display HTML content in a stage view port. It provides simple means to display HTML content on devices where the HTMLLoader class is not supported.

Some features of StageWebViewBridge:

  • Extends Bitmap class, you can modify his x,y,alpha,rotation,visible, etc ( Version 1 Beta )
  • Communicates Actionscript with Javascript.
  • Communicates Javascript with Actionscript.
  • Load local files and resources in a easy way.
  • Extends loadString method with AS3 – JS communication.
  • Extends loadString method to load local resources.
  • Lets you take an SnapShot to use as the bitmapData of the bitmap.

Sample

// create StageWebViewBridge instance
// new StageWebViewBridge( x,y,width,height )
var view:StageWebViewBridge = new StageWebViewBridge( 0, 150, 320, 280 );

// add listener for when page becomes loaded
view.addEventListener( Event.COMPLETE, onViewLoadComplete );

// enable javascript to call function helloWorldFromJS
view.addCallback('helloWorldFromJS', helloWorldFromJS );

// load content to the view
view.loadLocalURL('appfile:/index.html');

// as StageWebViewBridge extends Bitmap
// we can now add it to the displaylist
addChild( view );

// event listener that gets called on page load complete
function onViewLoadComplete( e:Event ):void
{
        trace('view loaded');
        // call a javascript function after the page loads
        // that will do an alert with the date passed from as3
        view.call('helloWorldFromAS3', null, new Date().toString() );
}

// function to be called from JS
function helloWorldFromJS( at:String ):void
{
        trace('helloWorldFromJS called from JavaScript at '+ at );
}
Misc . URL.