tags:

views:

149

answers:

0

I'm having problems updating the tree control with the current selected item based on the address bar.

so basically when i put this on the address bar:

main.html#/0.0 - category 1 should be selected main.html#/0.1 - category 2 should be selected

It seems that the variable I created (idset) is always null everytime it enters the initTree function

but if that is so, why is it that this part

<mx:Label id="lblTest" text="value: {idset}"/>

correctly displays the value entered on the address bar, but not reflected on the address bar.. Am I doing things wrong? I need help on this.. Thanks in advance:)

mxml:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:url="http://www.allurent.com/2006/urlkit"&gt;

    <mx:Script>
    <![CDATA[
        import mx.controls.Alert;
        [Bindable]
        private var idset:String;
     private function initTree():void {
      var vals:Array;   
      if (idset == null) {
       idset = '0.1';
      }
      vals = idset.split(".");
      Alert.show(vals[0]+'.'+vals[1],'popup');
         Puno.expandItem(msgList.getItemAt(vals[0]), true);
         Puno.selectedIndex = vals[1];
     }
    ]]>
    </mx:Script>

    <url:FlexBrowserManagerAdapter applicationState="{urlRules}" />
    <url:UrlRuleSet id="urlRules">
     <url:UrlValueRule id="treeRule" urlFormat="/*" 
      stringValue="{idset}" change="idset = treeRule.stringValue"/>
    </url:UrlRuleSet>
    <mx:XML id="activities" source="source.xml" />
    <mx:Panel title="Flex Tree:" x="3" y="3" width="300" height="400">
        <mx:Tree id="Puno" width="100%" height="100%" creationComplete="initTree();"
                change="idset = Puno.selectedItem.@rfid" labelField="@label">
      <mx:XMLListCollection id="msgList" source="{activities.node}" />
        </mx:Tree>
     <mx:Label id="lblTest" text="value: {idset}"/>
    </mx:Panel> 
</mx:Application>

xml:

<node label="Titles">
    <node label="Category 1" rfid="0.0"/> 
    <node label="Category 2" rfid="0.1">
     <node label="Sub Category 1" rfid="1.2"/>
     <node label="Sub Category 2" rfid="1.3"/>
     <node label="Sub Category 3" rfid="1.4"/>
    </node> 
    <node label="Category 3" rfid="0.2"/>
    <node label="Category 4" rfid="0.3"/>
</node>