如何获取movieclip的X,Y坐标(在另一个movieclip中)但相对于_root?

时间:2011-02-23 17:48:57

标签: flash actionscript actionscript-2 flash-cs3

我在另一个movieclip中有一个movieclip ...

//create on the stage an empty movieclip... 
var mc_container:MovieClip = _root.createEmptyMovieClip("container_name", _root.getNextHighestDepth());

//new position on the stage...
mc_container._x = 200;
mc_container._y = 200;

//create a movieclip inside the main movieclip...
var mc_inside:MovieClip = mc_container.attachMovie("mc_from_library", "mc_name", mc_container.getNextHighestDepth(), {_x:0, _y:0, _alpha:100});

我可以获取相对于容器movieclip的mc_inside._x和mc_inside._y属性,但是如何相对于mc_inside._x(舞台)获得mc_inside._y_root

1 个答案:

答案 0 :(得分:1)

使用localToGlobal:

var point:Object = {x:myClip.inner_mc._x, y:myClip.inner_mc._y};
myClip.inner_mc.localToGlobal(point);
trace(point.x)
trace(point.y)

http://help.adobe.com/en_US/as2/reference/flashlite/WS5b3ccc516d4fbf351e63e3d118ccf9c47f-7d06.html