function openNode(node)

        {

            tr.setIsOpen(node, true, false , false);

            var children = node.getChildNodes();

            for (var i = 0; i < children.length; ++i)

            {

                openNode(children[i]);

            }

        }

 

        <mx:Tree id="tr" height="200"

change="selectedNode=event.target.selectedItem" creationComplete="openNode(tr.dataProvider)" />

 

Matt

 

-----Original Message-----
From: joshbronson630 [mailto:[EMAIL PROTECTED]
Sent:
Monday, May 10, 2004 10:36 AM
To: [EMAIL PROTECTED]
Subject: [flexcoders] Traversing a Tree

 

I'm having trouble writing a simple function that expands all the
nodes in a Tree. Is there a method that returns the number of nodes?
If there is, I think I could replace my callto size() in the code
below with a call to this method and this would work:



<mx:Tree initialize="openTree()">

  <mx:Script>

    <![CDATA[

      function openTree()
      {
        for(var i=0; i<this.size(); ++i)
          this.setIsOpen(this.getTreeNodeAt(i), true);
      }
     
      ]]>
     
  </mx:Script>

<mx:Model id="TreeXML" source="Source.xml"/>

  <mx:dataProvider>
    {ThreadXML}
  </mx:dataProvider>
     
</mx:Tree>


Or is there a better way to traverse the Tree, perhaps recursively?



Reply via email to