Copy link to clipboard
Copied
I have a movie clip on stage with several other movie clips inside of it. How do I refer to each child so I might do stuff to it? I have done it once before by name, but I'd rather not rely on names:
private function setUpHotSpots():void { // loop through all the hot spots, hide them, and assign event handlers var i:int; var numberOfHotSpots:int = hotSpots_mc.numChildren; for (i = 0; i < numberOfHotSpots; i++) { this["hotSpot"+i].alpha=0; this["hotSpot"+i].addEventListener("hotSpotClicked", hotSpotClickHandler); } }
Copy link to clipboard
Copied
use:
for(var i:uint=0;i<parentobject.numChildren;i++){
var displayobject:DisplayObject=parentobject.getChildAt(i);
//
}