ershin69
ershin69

Reputation: 96

How to determine a sub movieclip position related to the stage?

Hi i have some movieclips like this one: game_mc.substage_mc.rightHand and inside the rightHand i have a thread_mc like this:

game_mc.substage_mc.rightHand.thread_mc

Ok so here is the thing, i need to access the thread.x and thread.y position related to the stage or substage_mc i don´t really care, but if i do this:

trace(game_mc.substage_mc.rightHand.thread_mc.x);

I only get the thread position related to the rightHand and not to the stage. Any help here?.

Upvotes: 1

Views: 2172

Answers (3)

Miha
Miha

Reputation: 301

Try localToGlobal:

var posX:int = game_mc.substage_mc.rightHand.thread_mc.x;
var posY:int = game_mc.substage_mc.rightHand.thread_mc.y;
trace(game_mc.substage_mc.rightHand.thread_mc.localToGlobal(new Point(posX, posY));

Upvotes: 1

Daniel
Daniel

Reputation: 35724

there is a function on the DisplayObject class called localToGlobal

that will give you the coordinates, but you need to keep scale in mind

Upvotes: 2

Sr.Richie
Sr.Richie

Reputation: 5740

You have to use the localToGlobal() method.

Here you can find some useful explanation:

Understanding localToGlobal

Use localToGlobal in AS3

Upvotes: 1

Related Questions