2 Replies Latest reply on Jun 2, 2007 8:35 AM by goingflex

    mx:tree not updating dynamically

    goingflex Level 1
      Hi
      I am trying to simulate a directory structure through a tree representation. I use a cfdirectory call through a RemoteObject and attach the result to an XML object which then becomes the tree dataprovider. The first time the tree opens fine with all directory nodes. Each time I chose a directory to fetch the underlying subfolders the tree component becomes messy as if the tree does not refresh dynamically.
      I am doing something wrong. Any ideas would be very welcome.


      var mytree_struct:XML;


      private function buildtree ():void {
      for (var i:int = 0; i < aResult.length; i++) {
      var newnode:XML = new XML();
      newnode = <directory label={aResult.getItemAt(i).Name} isBranch="true"> </directory>;
      mytree_struct=mytree_struct.appendChild(newnode);
      }

      My tree event handler which should add new nodes ( subfolders) of the selected folder. For the moment I am just trying it out with a test variable k.toString().

      public function treeChanged(event:Event):void {
      for (var k:int =0; k <10;k++ ) {
      var newnode:XML = new XML();
      var temp1:String = k.toString();
      newnode = <subdirectory label= {temp1} isBranch="true"> </subdirectory>;
      event.currentTarget.selectedItem.appendChild(newnode);
      }

      }