简体   繁体   中英

AS3 - addchild from stage to movieclip

I just tried to add the movieclip "box" to the "container.holder". Both movieclips are on stage. Nothing happends with this script.

container.holder.addChild(box); 

What do I miss there?

Edit

Maybe you forgot to stage.removeChild(box)?

Old

When you add box in holder you have to convert its "global" (stage) position to a "local" (holder) position using the globalToLocal method .

var global : Point = new Point(box.x, box.y);
var local : Point = container.holder.globalToLocal(global);
container.holder.addChild(box);
box.x = local.x;
box.y = local.y;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM