1 Reply Latest reply on Aug 25, 2006 11:44 AM by bnambooz

    Tree Data Population

    dzlmbq
      Can I not use ActionScript to populate my tree from a remote object call llike I use to in Flex 1.5? I am trying to upgrade an application to Flex 2. Here is the old code which has a few errors in the new Flex 2 builder. I guess the real question is do I have to use XML to populate a Flex 2 tree?

      private function getRootNodesHandler(success, result)
      {
      if (success) {
      parentNodes=result;
      childNodes=result;
      tempNodes=result;

      for (var i=0; i<parentNodes.length; i++) {
      if(parentNodes .nodeId == 0) {
      rootNode=trMainTree.addTreeNode(parentNodes
      .nodeTitle, parentNodes .codeId, parentNodes.nodeId);
      trMainTree.setIsBranch(rootNode);
      rootNode.isBranch="true";
      getChildNodes(parentNodes , rootNode);
      }
      if(parentNodes
      .nodeTitle == "Authors") {
      _tempNode=rootNode;
      techLoreService.getLoreAuthors();
      }
      }
      }
      }

      private function getChildNodes(nodex, nodePosition)
      {
      childCount=0;

      for (var j=0; j<tempNodes.length; j++) {
      if(nodex.codeId == tempNodes[j].nodeId) {
      var node=nodePosition.addTreeNode(tempNodes[j].nodeTitle, tempNodes[j].codeId, tempNodes[j].nodeId);
      childCount=childCount+1;
      }
      if(childCount==1) {
      var positionNode=tempNodes[j];
      getChildNodes(positionNode, node);
      }
      }
      }