RE: [flexcoders] Re: Total Number of Items in a Tree

2007-08-28 Thread Alex Harui
XML or ArrayCollection?  Probably have to recurse for AC  For xml, I
think you can do myxml..* or something like that.

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of bjorn -
Sent: Monday, August 27, 2007 1:51 AM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Re: Total Number of Items in a Tree

 

Make a recursive count function, maybe.

 

// pseudocode  for tree based on an arraycollection

 

function countNodes( ac:ArrayCollection ): int 

{

   var count:int = 0;

   for(var i:int=0; i  ac.length; i++) {

  count++;

  if(ac[i].hasOwnProperty('children')) {

 count += this.countNodes( ac[i].children );

  }

   }

   return count;

}

 

On 27/08/07, Stefan Schmalhaus [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]  wrote: 

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, Alex Harui [EMAIL PROTECTED] wrote: 

 Depends on what number you're looking for. The total number of
possible
 nodes or the total number based on what nodes are open

I'm looking for the total number of nodes (branches and leaves), no 
matter whether they are opened or not. 




-- 

 
http://www.juicability.com http://www.juicability.com  - flex blog
http://www.43min.com http://www.43min.com  - funny movies 

 



[flexcoders] Re: Total Number of Items in a Tree

2007-08-27 Thread Stefan Schmalhaus
--- In flexcoders@yahoogroups.com, Alex Harui [EMAIL PROTECTED] wrote:

 Depends on what number you're looking for.  The total number of possible
 nodes or the total number based on what nodes are open

I'm looking for the total number of nodes (branches and leaves), no
matter whether they are opened or not. 



Re: [flexcoders] Re: Total Number of Items in a Tree

2007-08-27 Thread bjorn -
Make a recursive count function, maybe.

// pseudocode  for tree based on an arraycollection

function countNodes( ac:ArrayCollection ): int
{
   var count:int = 0;
   for(var i:int=0; i  ac.length; i++) {
  count++;
  if(ac[i].hasOwnProperty('children')) {
 count += this.countNodes( ac[i].children );
  }
   }
   return count;
}


On 27/08/07, Stefan Schmalhaus [EMAIL PROTECTED] wrote:

   --- In flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Alex
 Harui [EMAIL PROTECTED] wrote:
 
  Depends on what number you're looking for. The total number of possible
  nodes or the total number based on what nodes are open

 I'm looking for the total number of nodes (branches and leaves), no
 matter whether they are opened or not.

 




-- 


http://www.juicability.com - flex blog
http://www.43min.com - funny movies