PDA

View Full Version : Display List confusion (simple question)



ShooterMG
September 26th, 2007, 06:00 PM
So I have:

var clip1:MovieClip = new MovieClip();
var clip2:MovieClip = new MovieClip();
var clip3:MovieClip = new MovieClip();

addChild(clip1);
clip1.addChild(clip2);

can anyone tell me why it won't let me go:
clip1.clip2.addChild(clip3);

What's the proper way to go about adding children to children?

BradLee
September 26th, 2007, 06:10 PM
You don't access things using their names anymore, you use the variables you used to create it. So to make something a child of clip2 you'd just do this:



clip2.addChild(clip3);


Of course, if you do set an object's name you can access it using getChildByName()

But MovieClips don't have an instance name by default. You have to set it like clip2.name = "whatever"

ShooterMG
September 26th, 2007, 06:21 PM
You don't access things using their names anymore, you use the variables you used to create it. So to make something a child of clip2 you'd just do this:



clip2.addChild(clip3);


Of course, if you do set an object's name you can access it using getChildByName()

But MovieClips don't have an instance name by default. You have to set it like clip2.name = "whatever"

Wonderful. Thanks for the tip :)