views:

41

answers:

2

Anybody any ideas on how to remove children from stage using AS3 if I store the reference to the objects in an array and they exist in different locations i.e they are not all children of the same parent?

SomeArray.push(this);

A: 

Consider this :

  • Iterate over each of the clips & their children.
  • Match the reference name/ID (I hope its a unique one).
  • Use removeChild to remove the display object(Sprite,MC,etc).
  • keep popping off the last reference off the array as you keep getting matches.
loxxy
Sounds like a plan, I have 3 collision objects that I attach children to but I want to keep the number of children inside all 3 objects to a maximum as not to soak up too much cpu.
woodscreative
+3  A: 
for each(var mc:MovieClip in SomeArray){
    mc.parent.removeChild(mc);
}
Daniel
this makes some assumptions, ideally you'd do it with a bit more fool-proofing, like checking if each mc does have a parent.
Daniel