Link to home
Start Free TrialLog in
Avatar of Angha110
Angha110

asked on

Add Child dynamically in a loop

Hi,

I am creating new instances from a movie clip in library and adding it to a container on the stage. I also need to add a child to that already added child. Some thing like this in a loop.

var bar:YearBar=new YearBar();
myContainer.addChild(bar);

then I have to do this:
 var cube:Cube=new Cube();

I want to add this to the bar, so I did this:
myContainer.bar.addChild(cube);

But I am getting error.
Please note all these are happening in a loop and I need to create different number of these instances.

What am I doing wrong?

Avatar of deepanjandas
deepanjandas
Flag of India image

Do this:
var bar:YearBar=new YearBar();
myContainer.addChild(bar);

var cube:Cube=new Cube();
bar.addChild(cube);

Open in new window


Warm Regards
Deepanjan Das
ASKER CERTIFIED SOLUTION
Avatar of Mohfath
Mohfath

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Angha110
Angha110

ASKER

Thank you for the responses. It works great.