Skip navigation
Currently Being Moderated

How to resize a StageWebView

Sep 18, 2013 12:19 PM

Tags: #view #stagewebview #stagewebview_size #view_resize #stageorientationevent

Hello,

I'm searching for some assistance with StageWebView on

Android. The code used to load the page is

below.

The code works everytime on my Android device and on

the desktop emulator.

I want to resize a View where is the StageWebView control, but however the StageOrientationEvent is passed correctly, strangely viewport width and viewport height aren't never changed :

 

import flash.display.Sprite;

import flash.display.StageAlign;

import flash.display.StageScaleMode;

import flash.events.StageOrientationEvent;

import flash.geom.Rectangle;

import flash.media.StageWebView;

import spark.components.View;

 

public class AfficherSimpleStageWebView extends Sprite

{

     private var _webView:StageWebView;

     private var strMyURL:String;

     protected var myView:View;

 

     public function DisplaySimpleStageWebView(view:View)

     {

          myView = new View();

          myView = view;

          strMyURL = myURL;

          this.addEventListener(Event.ADDED_TO_STAGE,init);

          this.addEventListener(Event.REMOVED,close);

     }

     private function init(e:Event):void

     {

          _webView = new StageWebView();

          stage.align = StageAlign.TOP_LEFT;

          stage.scaleMode = StageScaleMode.NO_SCALE;

          stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, onOrientationChange);

 

          _webView.stage = this.parent.stage;

          _webView.loadURL("web.page.url");

 

          onOrientationChange();

     }    

 

     protected function onOrientationChange(event:StageOrientationEvent=null):void

     {

          if(event!=null && (event.afterOrientation == "rotatedLeft" || event.afterOrientation == "rotatedRight")){ // "portrait" mode

               var horizontalBounds:int = (myView.height*0.83);

               _webView.viewPort.width = horizontalBounds;

               _webView.viewPort.height = myView.width-30;

          }

          else{ // "landscape" mode

               var verticalBounds:int = (myView.height*0.83);

               _webView.viewPort.width = myView.width-30;

               _webView.viewPort.height = verticalBounds;

          }

          if(textAreaDebug!=null)

               textAreaDebug.appendText(" AffichaerSimpleStageView -> onAdapterTailleSSWV : _webView.viewPort.width ="+(Number(stage.width)-15)+" - _webView.viewPort.height ="+verticalBounds);

     }

}

 

How I reference the class :

protected var mySSWV:DisplaySimpleStageWebView;

 

How I use the object in the "initialize" event :

mySSWV = new AfficherSimpleStageWebView(this);

 

Did I forget anything important in this code ?

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points