Pages

Saturday, April 28, 2012

How to get MovieClip X and Y position from child MovieClip to parent main MovieClip in AS3


Step 1: Change Movie clip to Object.
example:- Here have c_mc is child of b_mc and b_mc is a child of a_mc.

now we will find c_mc x and y postion in main stage

var obj:Object=new Object();
obj=a_mc.b_mc.c_mc;

Step 2: Get x and y position using with localToGlobal method.
var poi:Point=new Point(obj.x,obj.y);
poi=obj.parent.localToGlobal(poi);

poi.x and poi.y are c_mc movieclip x,y positions.
Thank you Friends 
...CHeeRS...

1 comments:

Unknown said...

Thank you so much this helped because it kept returning the value 0, 0 when I said obj.obj.x and obj.obj.y

Post a Comment