0 Replies Latest reply on Aug 23, 2006 4:20 AM by nippi

    Accordian and Dynamic TabNavigator

    nippi
      Hi All,

      I have an accordian dynamically generate from an XML file and within each tab it has tree menu. On selecting a tree node it opens up a TabNavigator dynamically... and keps adding a new child to it when a new node is opened. So is you have clicked 3 nodes in accordian it will open 3 tabs.

      What i want to achieve is say ur on 3rd tab and then you clicked on 1st tab.. the accordian should goto that tree node.. below is the code.

      Display Part

      <mx:HTTPService id="menuxml" url="expandMenu.xml" resultFormat="e4x" useProxy="false" result="resultHandler(event)" />

      <mx:HDividedBox width="100%" height="100%" id="menuDiv">
      <mx:Panel id="menuPanel" width="250" height="100%" headerHeight="0" borderStyle="solid" shadowDistance="0">
      <mx:Label text="Administration Menu" fontWeight="bold" />

      <mx:Accordion width="100%" height="100%" themeColor="#ff8000" fillColors="[#0000ff, #d9d9ff]" fillAlphas="[0.09, 1.0]" id="AccordianMenu">

      <mx:Repeater id="myRep" dataProvider="{myXML.node}">
      <mx:Canvas icon="@Embed(source='images/blank.jpg')" label="{myRep.currentItem.@label}" width="100%" height="100%">
      <mx:Tree id="prodTree" dataProvider="{myRep.currentItem.node}"
      height="100%" width="100%" showRoot="false" labelField="@label"
      itemClick="doTreeSelect(event)"
      folderClosedIcon="{noicon}" folderOpenIcon="{noicon}" />

      </mx:Canvas>
      </mx:Repeater>

      </mx:Accordion>
      </mx:Panel>

      <mx:TabNavigator id="windowTab" width="100%" height="100%">

      </mx:TabNavigator>

      </mx:HDividedBox>

      Selected AS part
      private function resultHandler(event:Event):void
      {
      myXML = event.target.lastResult;
      }

      private function doTreeSelect(e:Event):void
      {
      selectedNode=Tree(e.target).selectedItem;

      if (tabExists(selectedNode.@data) == true) {
      Alert.show("Tab already open " + selectedNode.@data);
      }
      else
      windowTab.addChild(newTab(selectedNode.@data));
      }

      private function tabExists(str:String):Boolean {
      return windowTab.getChildByName (str) != null;
      }

      private function newTab(str:String):Canvas {
      var tmpcon:Canvas = new Canvas();
      tmpcon.percentWidth = 100;
      tmpcon.percentHeight = 100;
      tmpcon.id = str;
      tmpcon.name = str;
      tmpcon.label = str;
      return tmpcon;
      }