开发者

AS3 - addchild from stage to movieclip

开发者 https://www.devze.com 2023-04-11 01:24 出处:网络
I just tried to add the movieclip \"box\" to the \"container.holder\". Both movieclips are on stage.

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); 

Wh开发者_运维技巧at 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;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号