point taken, thanks for the tip, valdhor. 
--- In flexcoders@yahoogroups.com, "valdhor" <valdhorli...@...> wrote:
>
> While that may work, I have found that anytime you are looping over an array 
> like this, modifying/deleting items in the array while iterating over it is 
> problematic at best.
> 
> I find the best way is to create a new array that holds the id's of the items 
> you want to delete and iterating over this new array and deleting specific 
> items in the original array is best.
> 
> --- In flexcoders@yahoogroups.com, "Matthew" <fumeng5@> wrote:
> >
> > I found that reversing the loop, i.e. decrementing thru it solves the 
> > problem. Hope that helps someone. 
> > 
> > --- In flexcoders@yahoogroups.com, "Matthew" <fumeng5@> wrote:
> > >
> > > Hi - 
> > > 
> > > I remove an item in an array using splice() and when there's one object 
> > > left in the array, the looping stops. Why is that? My loop is nested 
> > > within another loop but I thought it should iterate over everything first 
> > > before it goes back to the outside loop. Here's my code:
> > > 
> > > for( var i:int=0; i<dpLength; i++ ){
> > >                           var group:Object = model.groupingColl[i];
> > >                           var children:Array = group.children as Array;
> > >                                           
> > >                           /* if there are 2 items in 'children', the 
> > > first is 
> > >                              removed fine but then it doesn't iterate 
> > > over the one
> > >                              remaining. */
> > >                           for each( var acct:Object in children ){        
> > >                                   if( acct.selected == true ){
> > >                                           children.splice( i,1 );
> > >                                   }
> > >                           }
> > >                   }
> > >
> >
>


Reply via email to