--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> You fixed:
> 
> if(!numThings[i].selected){ //
> 
> correct?
> 
> numThings is an int, you need the array there.
> 
> Tracy
> 
>  
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of fumeng5
> Sent: Tuesday, June 24, 2008 12:39 PM
> To: [email protected]
> Subject: [flexcoders] Re: Looking for the right loop
> 
>  
> 
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> , "Tracy Spratt" <tspratt@> wrote:
> >
> > I think this line:
> > 
> > if(!numThings[i].selected){ //
> > 
> > should be:
> > 
> > if(!things[i].selected){ //
> > 
> > Tracy
> > 
> > 
> > 
> > ________________________________
> > 
> > From: [email protected] <mailto:flexcoders%40yahoogroups.com>
> [mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of Doug McCune
> > Sent: Tuesday, June 24, 2008 12:11 PM
> > To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> > Subject: Re: [flexcoders] Looking for the right loop
> > 
> > 
> > 
> > There's nothing wrong with your code. You can also use a for each loop
> > instead, which might be a bit faster, but doesn't give you elements in
> > any kind of order.
> > 
> > But you could try this for each loop:
> > 
> > for each(var thing:Object in things) {
> > 
> > if(thing.selected == false) {
> > 
> > //whatever
> > 
> > }
> > 
> > }
> > 
> > Just note that using a for loop from 0 to the number of items will
> give
> > you those items in order, but a for each loop will give you them in
> > non-sequential order.
> > 
> > Doug
> > 
> > On Tue, Jun 24, 2008 at 8:57 AM, fumeng5 <fumeng5@
> > <mailto:fumeng5@> > wrote:
> > 
> > Hi,
> > 
> > I'm confused on how to best create a loop to do the following:
> > discover if each element's "selected" property is set to false.
> > Basically, I just want to detect when all elements of my array have a
> > "selected" property set to false. 
> > 
> > Here's my code:
> > var numThings:int = things.length;
> > 
> > for (var i:int=0;i<numThings;i++){
> > if(!numThings[i].selected){ // 
> > } 
> > }
> > 
> > I know I'm not using the correct loop, I just can't figure out how to
> > better approach this problem. Any tips are very much appreciated.
> > Thank you. 
> > 
> > Fumeng.
> >
> Thank you for your quick responses. I've decided to add another var to
> my code and it's working just fine now:
> 
> var thingsNotSelected:int = 0;
> var numThings:int = things.length;
> 
> for (var i:int=0;i<numThings;i++){
> if(!numThings[i].selected){
> thingsNotSelected++;
> } 
> }
> if(thingsNotSelected == numThings){
> // I know everything inside the array is not selected.
> }
> 
> Thank you again for your help.
> 
> Fumeng.
>
correct. nice catch. 

thanks. 

Reply via email to