In AS3
, I am trying to add a child to a specific child of a MovieClip
.
To do this I have done the following:
for (var r:Number = 0; r < 2; r++) {
sand = new Sand();
sLayers.getChildAt(r).addChild(sand);
}
When sLayers
is the MovieClip
parent, r
is the specific child of sLayers
, and sand
is the child I want to add.
It comes up with the following error:
1061: Call to a possibly undefined method addChild
through a reference with static type flash.display:DisplayObject.
Sorry I simplified the code, it would take up too much space.
Is there another way to do this? Or am I close but just missing something?
try this