StageWebView Loading Improved

Recently, someone asked about trying to improve hiding the white rectangle of the StageWebView. I got to thinking about this and tried a little experiment. Did I have to set the viewPort during the normal configuration, or could I wait?

So, I decided to try it. I moved the setting of the StageWebView’s viewPort until the page had been loaded. We know this via an Event.COMPLETE event. Here is the sample code:

import flash.media.StageWebView;
import flash.events.Event;

var webView:StageWebView = new StageWebView();
webView.stage = this.stage;
//webView.viewPort = new Rectangle(0, 0, 480, 200);
webView.assignFocus();
webView.loadURL("http://aj-software.com/clients/mobile/360Flex/2011/mobile/map/index.html");

webView.addEventListener(Event.COMPLETE,handleLoad);

function handleLoad(evt:Event):void
{
webView.viewPort = new Rectangle(0, 0, 480, 300);
}

stop();

Demo File

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s