Reputation: 1095
I have a MC with movieclips and shapes. Is there a way to loop throuh each child but only for MovieClips? I keep getting a null object because of the shape.
for (var i:int = 0; i < this.numChildren; i++) {
var obj:MovieClip = getChildAt(i) as MovieClip;
}
Here I thought "as MovieClip" would only trace out MovieClips...
Upvotes: 2
Views: 402
Reputation: 4530
for (var i:int = 0; i < this.numChildren; i++) {
if( getChildAt(i) is MovieClip ){
var obj:MovieClip = getChildAt(i) as MovieClip;
...
}
}
Upvotes: 3