Did I hear someone say 'fancy?' The best loop. isn't one! Especially if you have other mechanisms, like events, that can help reduce the cost of keeping track of a particular item. I've coded two classes; Thing and ThingCollection as an example.
http://www.quilix.com/node/16 Overkill? Don't much care. can't sleep anyway. Rick Winscot From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Toby Ashley Sent: Tuesday, June 24, 2008 12:02 PM To: [email protected] Subject: Re: [flexcoders] Looking for the right loop There are fancier ways of doing it I'm sure, but changing your code to the following will make it work. var numThings:int = things.length; var nothingSelected:Boolean = true; for (var i:int=0;i<numThings;i++){ // note that it should be things[i] below, not numThings[i] , as numThings is just an integer. if( things[i].selected ){ nothingSelected = false; } } // traces true if 0 items are "selected", false if one or more is "selected" trace (nothingSelected); On Tue, Jun 24, 2008 at 4:57 PM, fumeng5 <[EMAIL PROTECTED]> 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. ------------------------------------ -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links

