1 Reply Latest reply on May 31, 2011 10:32 PM by mattdwm

    Making a full StageWebView that resizes

    mattdwm Level 1

      I'm having a lot of trouble getting a stagewebview to resize when the device is rotated. I don't understand how to get stage not null. How do you get the dimensions below the top navigation bar? (fxp file)

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView" creationComplete="creationCompleteHandler(event)" resize="resizeHandler(event)">
           <fx:Script>
                <![CDATA[
                     import mx.events.FlexEvent;
                     import mx.events.ResizeEvent;
                     
                     private var swv:StageWebView;
                                                   
                     protected function creationCompleteHandler(event:FlexEvent):void
                     {
                           if (StageWebView.isSupported==true)
                          {
                               swv = new StageWebView();
                               resizeSWV();
                               swv.stage = stage;
                               swv.loadURL("http://www.google.com");
                          } 
                           
                     }
                     
                     protected function resizeHandler(event:ResizeEvent):void
                     {
                          resizeSWV(); 
                     }
                     
                     private function resizeSWV():void
                     {
                          if (swv != null)
                          {
                               swv.viewPort = new Rectangle(0, stage.height - height, width, height);
                          } 
                     }
                     
                ]]>
           </fx:Script>
      </s:View>
      
      

        • 1. Re: Making a full StageWebView that resizes
          mattdwm Level 1

          The way I found to get the dimensions is like this:

           

          private var app:ViewNavigatorApplication = FlexGlobals.topLevelApplication as ViewNavigatorApplication;
          
          
          trace("app.navigator.actionBar.height = "+app.navigator.actionBar.height);
          
          
          trace("app.navigator.activeView.height = "+app.navigator.activeView.height);
          

           

          But I'm still not able to get the stage object. I would have thought that it would be initialized after creationComplete.