Why does it get complex with nested sets of child components? Why
can't you just use a recursive function?

function doSomethingToAllDescendants(component :
DisplayObjectContainer) : void {
   for (var i : int = 0; i < component.numChildren; i++) {
      doSomethingToComponent(component.getChildAt(i));
      if (component.getChildAt(i) is DisplayObjectContainer)
        
doSomethingToAllDescendants(DisplayObjectContainer(component.getChildAt(i)));
   }
}

Sorry if i left out some curlies or semicolons here.

Adam

--- In [email protected], Jurgen Beck <[EMAIL PROTECTED]> wrote:
>
> I need to traverse the list of all children in a component. What's  
> the best approach to doing that? It gets fairly complex with nested  
> sets of child components, so I'm looking for an efficient solution.
> 
> Thanks,
> 
> Jurgen
>


Reply via email to