I'm confused... Sprite doesn't have a 'children' property, and you can't do a for-each-in loop over something that doesn't exist. Are you asking "Why doesn't Sprite have a 'children' Array rather than a numChildren property and a getChildAt() method?". The answer to that is that AS3 lacks strongly typed Arrays, and lacks a way to know when you've modified an Array. For example, if you pushed a Sprite onto the Array, the Player wouldn't know to add it to the display list. Gordon Smith Adobe Flex SDK Team
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of kjorn Sent: Monday, February 25, 2008 5:00 AM To: [email protected] Subject: [flexcoders] Re: Sprite.children --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Troy Gilbert" <[EMAIL PROTECTED]> wrote: > > > In my Sprite object, how come I can't do: > > > > for each( var child:Sprite in this.children ) { > > // do something > > } > > > > I can do a simple for loop, but this can not be run in parallel on a > > multicore chip. Whereas the above code could (100 children, 100 cores > > on my chip = each core runs the code) > > In theory, yes, a foreach could be optimized by a compiler to leverage > mutlicores whereas a forloop cannot... but in the case of Flash, in > particular the AVM2 (the Actionscript Virtual Machine v2) is not > designed to distribute code across multiple cores. > > If that's something that you're looking for, Flash may be the wrong > environment for you... ;-) > > Troy. > No, I just want to do this: for each( var child:Sprite in this.children ) { // do something } I'm not bothered about 100 cores :-) Why do I have to use a normal for loop? Why can't I do for each? Is it a technical reason inside Sprite? monk.e.boy

