0 Replies Latest reply on Jan 8, 2011 11:03 PM by Guha2000

    ViewStack/ TabNavigator- MXML + ActionScript

    Guha2000

      I have a situation where I need to build the tabs in a tabNavigator using a combination of MXML (for common content) and AS (for specific content)- essentially MXML for the first and last tab, with AS content for the middle contents

       

      Even when i have a tab of 0 and 4 for the mxml and AS set to tabs 1,2 and 3 - the way it is rendered is that sometimes content of mxml screen dont get wiped off when when the AS-created tabs are clicked. e.g. in sample, in clicking button while mxml tab 2 is selected, AS-tab2 gets  selected with mxml text still present in the first round. Any idea why this happens?

       

      I am using functions as below

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

      <s:Application

       

       

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

      xmlns:s="

      library://ns.adobe.com/flex/spark"

      xmlns:mx="

      library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

       

       

      <fx:Declarations>

       

       

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

       

       

      </fx:Declarations>

       

       

      <fx:Script>

      <![CDATA[

       

       

      import spark.components.NavigatorContent;

       

      private function init():void

      {

       

      var temp1:NavigatorContent = new NavigatorContent();

      temp1.label=

      "as-temp1"

       

      var temp2:NavigatorContent = new NavigatorContent();

      temp2.label=

      "as-temp2"

       

      var temp3:NavigatorContent = new NavigatorContent();

      temp3.label=

      "as-temp3"

      tabNav.addElementAt(temp1,1)

      tabNav.addElementAt(temp2,2)

      tabNav.addElementAt(temp3,3)

      tabNav.selectedIndex=2;

      }

      ]]>

       

      </fx:Script>

       

      <mx:TabNavigator id= "tabNav" creationPolicy="all" x="20" y="100" height="300" width="800" tabWidth="150">

       

      <s:NavigatorContent id="navg0" label="mxm-temp0" tabIndex="0">

       

      <s:Label text ="in tab 0"/>

       

      </s:NavigatorContent>

       

      <s:NavigatorContent id="navg2" label="mxm-temp4" tabIndex="4">

       

      <s:Label text= "in tab 4"/>

       

      </s:NavigatorContent>

       

      </mx:TabNavigator>

       

      <s:Button click="init()"/>

      </s:Application>