1 Reply Latest reply on Sep 22, 2013 3:17 PM by Youtch

    How to resize a StageWebView



      I'm searching for some assistance with StageWebView on

      Android. The code used to load the page is


      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;




           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;






           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;



                     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 ?

        • 1. Re: How to resize a StageWebView
          Youtch Level 1

          I've understood the source of my problem, it can be useful for somebody :

          I wanted to use StageOrientationEvent ! But it works really good by using the event Resize. I linked this one to myView, the MXML View object which have a mapping in the class. On init() I added that :




          Also I had to modify the size of Rectangle, the primitive object. After have detect that I add this one and it works good... I used that :


          protected function onStageResized(event:Event):void


              _webView.viewPort = null;

              var verticalBounds:int = myView.height;

              _webView.viewPort = new Rectangle(0, 30 , View.width, verticalBounds);



          Simply but useful ;-)