Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
abeall webforumsuser@macromedia.com #1
MC absolute coordinates?
When you have nested MCs, the coordinates of a nested MC will be relative where it is in relation to the reg point of its parent MC. Is there a way to get the absolute _x and _y coordinates of a nested MC? In other words, find out where the reg point of an MC falls on the _root timeline even when it's nested?
TIA
-beally-
-------------------------
"Senior Member" - experienced at messing things up
CurrentProject - feedback appreciated
abeall webforumsuser@macromedia.com Guest
-
Convert user space coordinates to device coordinates
Hi, I need to convert the coordinates of a word (PDWord object) to device coordinates (the actual coordinates on the screen). Could someone please... -
x and y coordinates
Is there a way to enter the x and y coordinates of an object to change its position on the page. I see the info pallette gives the x and y... -
absolute coordinates
hi all, I hope this is not a silly question, but I would a) like to display the position of an object in absolute coordinates and b) enter manually... -
absolute or relative _x/_y coordinates
Hello friends, allrite here it goes. I have three clips. Lets call'em: clip0,clip1 and clip2 clip1 is INSIDE clip0 -
Some help with coordinates please!
Hullo! Ok, so, I have this friend (clichè? no, no, I swear it's true!) that has a problem. I thought i could help her but I couldn't after all. ... -
abeall webforumsuser@macromedia.com #2
Re:MC absolute coordinates?
UPDATE
the obvious solution would be to add the parent coordinates to the child coordinates, and the sum should be the child's _root coordinates. The problem is, if the parent is rotated, the child(if not directly at reg point of parent) will be moved on the _root but not on the parent, so the above wont work. I have figured out a really round about way to counter this using calculus, but is there no absolute coordinates function?
-beally-
-------------------------
"Senior Member" - experienced at messing things up
CurrentProject - feedback appreciated
abeall webforumsuser@macromedia.com Guest
-
Bertrand Saint-Guillain #3
Re: MC absolute coordinates?
"abeall" [email]webforumsuser@macromedia.com[/email] wrote:
Q > When you have nested MCs, the coordinates of a
nested MC will be relative where it is in relation to
the reg point of its parent MC. Is there a way to get the
absolute _x and _y coordinates of a nested MC? In other
words, find out where the reg point of an MC falls on
the _root timeline even when it's nested?
A : check MovieClip's localToGlobal method
In your case the solution would be - provided that your root is
not scaled nor moved - something like for instance :
var p={x:0,y:0};
parentMc.anotherMc.mc.localToGlobal(p);
// or
var path = parentMc.anotherMc;
var myMc = path.mc;
var p={x:myMc._x,y:myMc._y};
parentMc.anotherMc.localToGlobal(p);
then to retrieve these absolute coordinates in any mc
coordinate space:
anyMc.globalToLocal(p);
you could also try something like:
MovieClip.prototype.getAbsoluteCoordinates = function () {
var p= { x : this._x , y : this._y };
this._parent.localToGlobal(p);
return p;
};
MovieClip.prototype.getLocalCoordinates =
function (/*MovieClip*/ targetMc) {
var p= { x : this._x , y : this._y };
this._parent.localToGlobal(p);
targetMc.globalToLocal(p);
return p;
};
// sample code:
d.onEnterFrame=function() {
var p = a.b.getLocalCoordinates(d);
d.c._x=p.x;
d.c._y=p.y;
};
// on the root timeline clip b is nested in clip a
// and clip c is nested in clip d
// suppose b has a motion tween within a
// both a and d can be rotated and/or scaled
// and/or skewed and
// no matter how deep mc's are nested
NB: getBounds doesn't answer specifically your question but
is in some way related since it takes a "target
coordinate space" parameter, you couldn't achieve the
same result - but it might be useful.
HTH,
--
Bertrand Saint-Guillain
[url]http://www.supersatori.com/[/url]
Bertrand Saint-Guillain Guest
-
abeall webforumsuser@macromedia.com #4
Re: MC absolute coordinates?
hey
still haven't gotten around to trying this idea out, it looks complex, but I'll give it a shot.
let me see if I get this. the localToGlobal method takes a point object, and will convert it to a global point?
I'll try it out, thanks
-beally-
-------------------------
"Senior Member" - experienced at messing things up
CurrentProject - feedback appreciated
abeall webforumsuser@macromedia.com Guest



Reply With Quote

