1 Reply Latest reply on Aug 15, 2013 6:03 AM by firda.cz

    Having a problem to remove stageWebView when I switch the tab in the tabbed View Application

    Rajarajan Ottawa

      Hi

       

      I'm using tabbed flex mobile application for iPad, I've four tabs in my app, First tab has split view and other tabs have stage web view. When I switch the tabs I could not get rid of stageWebView. Could you please help me fix this issue.

       

      main.mxml

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                                       xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="320" splashScreenImage="@Embed('images/logo.png')"  splashScreenMinimumDisplayTime="2000" persistNavigatorState="true>

       

       

        <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

        </fx:Declarations>

       

        <fx:Style source="style/theme.css"/>

       

        <s:ViewNavigator label="Lodges and Resorts Directory"  width="100%" height="100%" firstView="views.HomeView"   />

        <s:ViewNavigator label="Ontario Fishing Regulations" width="100%" height="100%" firstView="views.FishingView/>

        <s:ViewNavigator label="Ontario Hunting Regulations"   width="100%" height="100%" firstView="views.HuntingView"/>

                <s:ViewNavigator label="Credits"  width="100%" height="100%" firstView="views.CreditsView"/>

       

      </s:TabbedViewNavigatorApplication>

       

       

      HomeView.mxml

       

      <?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" actionBarVisible="false" creationComplete="init()">

       

       

                <s:SplitViewNavigator id="svn" width="100%" height="100%">

                          <s:ViewNavigator id="leftNav" width="45%" height="100%" firstView="views.leftView"/>

                          <s:ViewNavigator id="rightNav" width="100%" height="100%" firstView="views.rightView" />

        </s:SplitViewNavigator>

      </s:View

       

       

      Leftview.mxml

       

      <?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="Regions"  creationComplete="getRegion.send(); init()" >

       

       

       

       

        <fx:Script>

                <![CDATA[

                          import mx.collections.ArrayCollection;

                          import mx.events.FlexEvent;

                          import mx.rpc.events.ResultEvent;

       

                          import spark.components.BusyIndicator;

                          import spark.events.IndexChangeEvent;

                          import spark.events.ViewNavigatorEvent;

       

       

                          [Bindable]

                          protected var regionList:ArrayCollection;

       

       

                          protected  var bi:BusyIndicator = new BusyIndicator();

                          

        protected function init():void

                          {

       

                                    this.addElement(bi);

                                    bi.visible = true;

       

                                    addEventListener(ViewNavigatorEvent.VIEW_ACTIVATE, viewActivate);

                                    addEventListener(ViewNavigatorEvent.VIEW_DEACTIVATE, viewDeactivate);

                                    addEventListener(ViewNavigatorEvent.REMOVING, viewRemoving);

                          }

                          protected function viewActivate(event:ViewNavigatorEvent):void

                          {

        //trace ("View Activated");

                                    bi.visible = false;

       

                          }

       

                          protected function viewDeactivate(event:ViewNavigatorEvent):void

                          {

        //trace ("View Deactivated");

                          }

       

                          protected function viewRemoving(event:ViewNavigatorEvent):void

                          {

        //trace ("View Removing");

                          }

       

       

                          protected function getRegion_resultHandler(event:ResultEvent):void

                          {

        // TODO Auto-generated method stub

                                    regionList = event.result.list.category;

       

                          }

       

       

       

                          protected function getInfo_changeHandler(event:IndexChangeEvent):void

                          {

        // TODO Auto-generated method stub

                                              navigator.pushView(views.leftViewList, getInfo.selectedItem);

                          }

       

       

       

                ]]>

        </fx:Script>

       

       

       

       

       

       

                <s:List top="0" bottom="0" left="0" right="0" dataProvider="{regionList}" id="getInfo"    change="getInfo_changeHandler(event)"   width="100%" chromeColor="red" fontLookup="embeddedCFF">

       

       

        <s:itemRenderer >

        <fx:Component>

                                              <s:IconItemRenderer labelField="region" decorator="@Embed('images/right_indicator.png')" iconWidth="70" iconHeight="80>

       

        </s:IconItemRenderer>

        </fx:Component>

        </s:itemRenderer>

        </s:List>

       

        <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

                          <s:HTTPService url="http://thepixelbowl.com/odo/odo_lists.php" id="getRegion" result="getRegion_resultHandler(event)">

       

        </s:HTTPService>

        </fx:Declarations>

       

       

       

       

      </s:View>

       

      rightview.mxml

       

      <?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="Resort Information"   destructionPolicy="never"  xmlns:views="views.*">

       

       

        <fx:Declarations>

        <!-- Place non-visual elements (e.g., services, value objects) here -->

        <fx:String id="websiteString">{data.website}</fx:String>

        <fx:String id="mapString">{data.maplink}</fx:String>

        <fx:String id="idString">{data.id}</fx:String>

        </fx:Declarations>

       

       

       

        <fx:Script>

                          <![CDATA[

                                    import flash.net.navigateToURL;

                                    import mx.events.FlexEvent;

                                    import spark.events.ViewNavigatorEvent;

       

                                    protected function button1_clickHandler(event:MouseEvent):void

                                    {

        // TODO Auto-generated method stub

                                              navigator.pushView(views.weblink, websiteString);

                                    }

       

                                    protected function button_clickHandler(event:MouseEvent):void

                                    {

        // TODO Auto-generated method stub

                                              navigator.pushView(views.maplink, mapString);

                                    }

       

                          ]]>

        </fx:Script>

       

       

       

       

       

       

        <s:VGroup>

       

        <s:HGroup>

                                    <s:BitmapImage source="images/welcome_logo.png"  visible="{data==null?true:false}" smoothingQuality="high" smooth="true" />

        </s:HGroup>

       

       

        <s:TextArea borderVisible="false"  contentBackgroundAlpha="0" textAlign="left" color="0x3bc5f3" letterSpacing="20" fontSize="38" verticalScrollPolicy="on" x="630" y="220" width="1350" height="550" editable="false" text="The Outdoor Directory Ontario Guide showcases Ontario lodges, resorts and campgrounds. The Guide promotes Ontario as a premiere four-season vacation destination. The Outdoor Directory Ontario Guide will assist in planning your next vacation. &#13; &#13;The benefits of the Outdoor Directory Ontario Guide are:&#13;

                                                        &#13;- Find new resorts that you have never visited.

                                                        &#13;- Find contact information including season and off season phone numbers.

                                                        &#13;- Find company websites easily.

                                                        &#13;- Find Youtube and Facebook sites for the resorts you like.

                                                        &#13;- Find Maps for the places you like &#13;

                                                        &#13;From the Publishers of Outdoor Directory Ontario we thank you for allowing us the privilege of serving your vacation and tourism needs. Enjoy!"   visible="{data==null?true:false}" >

       

        </s:TextArea>

       

                          <s:BitmapImage source="images/ontario_regions_map.png"  visible="{data==null?true:false}" smoothingQuality="high" smooth="true" />

       

       

        </s:VGroup>

       

       

       

       

       

                <s:HGroup id="hgroup" chromeColor="110011" >

                          <s:Scroller width="1400" height="1300" horizontalScrollPolicy="off" verticalScrollPolicy="on" >

        <s:Group>

        <s:layout>

        <s:VerticalLayout />

        </s:layout>

                                              <s:Label text="{data.resort}" visible="{data!=null?true:false}"  fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

       

                                              <s:Label text="{data.description}" visible="{data!=null?true:false}" width="1350" paddingTop="30" paddingLeft="30" />

       

                                              <s:Label text="Owner: {data.ownername}" visible="{data!=null?true:false}" fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

                                              <s:Label text="Address: {data.postbox}, {data.address}" visible="{data!=null?true:false}" fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

                                              <s:Label text="{data.city}, {data.province}, {data.postalcode}" visible="{data!=null?true:false}" fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

                                              <s:Label text="Phone: {data.telephone}" visible="{data!=null?true:false}" fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

                                              <s:Label text="Fax: {data.fax}" visible="{data!=null?true:false} null" fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

                                              <s:Label text="Toll Free: {data.tollfree}" visible="{data!=null?true:false}" fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

                                              <s:Label text="Winter Tel: {data.wintertel}" visible="{data!=null?true:false}" fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

                                              <s:Label text="Email: {data.email}" visible="{data!=null?true:false}" fontSize="40" color="0x333" fontWeight="bold" paddingTop="30" paddingLeft="30"/>

       

                                              <s:VGroup paddingLeft="30">

                                                        <s:Button label="Website" id="button" visible="{data!=null?true:false}" click="button1_clickHandler(event)">

        </s:Button>

                                                        <s:Button label="Map Direction" visible="{data!=null?true:false}" click="button_clickHandler(event)"></s:Button>

       

       

       

        </s:VGroup>

       

       

       

       

       

        </s:Group>

        </s:Scroller>

        </s:HGroup>

       

       

       

       

       

       

       

      </s:View>

       

       

       

       

       

       

       


        • 1. Re: Having a problem to remove stageWebView when I switch the tab in the tabbed View Application
          firda.cz

          I am using WebView wrapper and making it invisible in viewDeactivate event (it clears stageWebView.stage). It is working while my app is active, but having problems when I send it to background... sometimes the WebView refuses to work again

           

          <View xmlns="library://ns.adobe.com/flex/spark" xmlns:x="http://ns.adobe.com/mxml/2009" xmlns:v="views.*"

              title="Position" backgroundAlpha="0" destructionPolicy="never"

              viewActivate="init()"

              activate="init()"

              viewDeactivate="web.hideWebView()"

              deactivate="web.hideWebView(true)">

           

          private function init():void {

              if(!isActive) { web.hideWebView(); return; }

              web.showWebView();

           

          /** Hides the web view @see flash.media.StageWebView#stage */

          public function hideWebView(destroy:Boolean = false):void {

              if(_webView == null) return;

              _webView.stage = null;

              if(!destroy) return;

              _webView.dispose();

              _webView = null;

          }

          /** Displays the web view @see flash.media.StageWebView#stage */

          public function showWebView():void {

              if(_webView != null) {

                  webView.stage = stage;

                  return; }

              _visibleChanged = true;

              invalidateProperties();

              invalidateSize();

              invalidateDisplayList(); }

          /** @copy mx.core.UIComponent#commitProperties() */

          override protected function commitProperties():void {

              super.commitProperties();

              if(_visibleChanged) {

                  webView.stage =  visible ? stage : null;

                  _visibleChanged = false; }

              if(_sourceChanged) {

                  webView.loadURL(source);

                  _sourceChanged = false; }}

          /** @private */

          public function get webView():StageWebView {

              if(!_webView) webView = new StageWebView();

              return _webView; }

          /** @copy flash.media.StageWebView */

          public function set webView(value:StageWebView):void {

              if(_webView == value) return;

              if(_webView) {

                  _webView.removeEventListener(Event.COMPLETE, completeHandler);

                  _webView.removeEventListener(ErrorEvent.ERROR, errorHandler);

                  _webView.removeEventListener(FocusEvent.FOCUS_IN, focusInViewHandler);

                  _webView.removeEventListener(FocusEvent.FOCUS_OUT, focusOutViewHandler);

                  _webView.removeEventListener(LocationChangeEvent.LOCATION_CHANGING, locationChangingHandler);

                  _webView.removeEventListener(LocationChangeEvent.LOCATION_CHANGE, locationChangeHandler); }

              _webView = value;

              _webView.addEventListener(Event.COMPLETE, completeHandler);

              _webView.addEventListener(ErrorEvent.ERROR, errorHandler);

              _webView.addEventListener(FocusEvent.FOCUS_IN, focusInViewHandler);

              _webView.addEventListener(FocusEvent.FOCUS_OUT, focusOutViewHandler);

              _webView.addEventListener(LocationChangeEvent.LOCATION_CHANGING, locationChangingHandler);

              _webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, locationChangeHandler);

              _webView.stage = visible ? stage : null;

              _visibleChanged = false;

              if(source) _webView.loadURL(_source);

              _sourceChanged = false;

              invalidateDisplayList();

          }