I encountered the same problem and wrote my own version. 

public var categoryNodes:XML = new XML(); // xml data of the tree set
elsewhere
public var arrayFromNodes:ArrayCollection = new ArrayCollection();
public var nodeCount:Number = 0;

/**
* returns an xml node based on a tree index 
*/
public function getNodeAt(index:Number):XML{
  arrayFromNodes = new ArrayCollection();
  nodeCount=0;
  arrayFromNodes.addItem(categoryNodes[nodeCount]);
  getNodeList(XMLList(categoryNodes));
  return XML(arrayFromNodes.getItemAt(index));
}

/**
* returns a flattend node listing from an xml tree
*/
private function getNodeList(currentList:XMLList):void{
  for each(var childIndex:XML in XMLList(currentList.children())){
    nodeCount++
    arrayFromNodes.addItem(childIndex);  
    if(XMLList(childIndex).children().length()){
      getNodeList(XMLList(childIndex))
    }
  }
}

As to the expandChildrenOf() function it works for me by passing in
the root node for the tree dataProvider.

--- In [email protected], "carl_steinhilber"
<[EMAIL PROTECTED]> wrote:
>
> Well, now I'm stymied.
> 
> With Flex 1.5, I was able to expand all the nodes of an mx:Tree with
> something like:
> 
>    function setOpenAll(aryNodes):Void{
>                       
>       var childNode = aryNodes.getTreeNodeAt(0);
>       var aryChildren = aryNodes.getChildNodes();
> 
>       for (var i = 0;i < aryChildren.length;i = i + 1){
>          childNode = aryNodes.getTreeNodeAt(i);
>          treeElem.setIsOpen( myNode, true, false, false);
>          if ( childNode.hasChildNodes() ){
>               setOpenAll(childNode );
>          }
>       }
>    }
> 
> and invoke it with a button function like
> 
>    click="setOpenAll(treeElem.dataProvider)"
> 
> 
> But this throws an error in Flex 2. Near as I can tell... there's no
> getTreeNodeAt() function anymore.
> 
> Anyone know how to go about expanding all the nodes of a tree, now, in
> Flex 2? I'm continually surprised there are no methods
> openAll()/closeAll() for the Tree. Seems like the new
> expandChildrenOf() method would make things easier... but not quite
> sure how to use it.
> 
> Thanks in advance,
> -Carl
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to