Hey Guys,
First of all, a merry Christmas to you all. Better hope its not as snowy at your place as it is at mine. Can’t even get my front door to open.
Anyways, I have been referring to the sticky topic of “AS3: Tip of the Day” for more times than I can count in the past, yet I have a question regarding one of the things discussed in there.
When dealing with the For-Each loop, the example is given of getting all values within an Array. I want to use the For-Each loop for a dynamically created Sprite but it does not work.
This is the code:
var thumbnails = new Sprite();
addChild(thumbnails);
for(var i=1; i<= A_XML.assignment.length(); i++)
{
var newThumbnail:IndexThumbnail = new IndexThumbnail(...);
thumbnails.addChild(newThumbnail);
}
for each(var child:IndexThumbnail in thumbnails)
{
trace(child)
}
I don’t want to use for(var i=0;i<thumbnails.numChildren;i++) because the index might be messed up (no child at index0 but instead at 2) because I remove some and I think for each would be a more elegant solution to approach this.
Thanks in advance!