View Full Version : geting x y position of a MC in a MC
MadWilson
05-29-2003, 07:34 PM
I have a MC that contains more MC's inside it how can I get the _x and _y of the MC's that resides inside the _root.MC. Note that I am moving the _root.MC around the screen with key presses and need the new location of the MC's inside the _root.MC.
Thanks
madwilson
pellepiano
05-29-2003, 07:52 PM
You can set some variables i the root that gets the sub mc's positions.
getThe_x=_root.mc1.subMC1._x;
getThe_y=_root.mc1.subMC1._y;
senocular
05-29-2003, 08:06 PM
The location of the movieclips in the main MC will always be the same if they arent moved as well since their position is based within the MC timeline. The MC exists in _root and can move anywhere it wants to there and the inner movieclips will show the same locations, since, to them, no movement has occurred. They are still where they were before in terms of MC's timeline.
If you need to know where they are in relation to _root, though, since visually their position has changed (on the whole, just not in MC) then you can use localToGlobal which will allow you to conert their current 'local' positions into 'global' or _root positions.
ex:
_root.MC._x = 100;
_root.MC._y = 100;
_root.MC.innerClip._x = 50;
_root.MC.innerClip._y = 50;
pointToConvert = new Object();
pointToConvert.x = _root.MC.innerClip._x;
pointToConvert.y = _root.MC.innerClip._y;
_root.MC.localToGlobal(pointToConvert);
trace(pointToConvert.x +", "+ pointToConvert.y); // traces 150, 150
hivoltmedia
07-28-2003, 11:51 AM
What if I would have 10 clips inside of an MC, where I would need to convert localToGlobal values? Each one has a unique _x and _y value.
Any ideas?
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.