Flasher Archive

[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]


Subject: RE: [flasher] Re: X and Y coordinates - Confusion!
From: Paul Willoughby
Date: Mon, 26 Feb 2001 13:52:24 -0000

Call me stupid and/or lazy but I just don't get F5's localToGlobal, the
example code in the manual seems excessive for such a meagre task (although
I admit manual examples aren't always the best written!). I prefer to use
the old Flash 4 hack of just adding the parent clip and local clips x
position. Try this code on the nested movie clip on an enterFrame action
when you're dragging a parent clip around:

// local to global

myLocalX = this._x;
myGlobalX = _parent._x - this._x;
trace("the nested clips local x is: " + myLocalX);
trace("the nested clips global x is: " + myGlobalX);
trace("-------------------------------------------");

this can get a bit hairy if you need to get the global position of a clip
nested 6 deep, but it gets the job done ;)

hth

paul

BTW why are there 9 little boxes on the object panel when you can only
select the middle or top left as the registration point?


> -----Original Message-----
> From: Muzak [muzakatpandora [dot] be (mailto:muzakatpandora [dot] be)]
> Sent: 26 February 2001 12:36
> To: flasher from chinwag
> Subject: [flasher] Re: X and Y coordinates - Confusion!
>
>
> If you select an object on the stage. The x and y coordinates
> shown will be the top left corner of the object. If you then select
> the little white square in the middle of the 9 boxes, it will
> turn black and the x and y coordinates of the object shown in the info
> panel are now the center point of the object (in refence to
> it's parent) instead of the top left corner.
>
> When using the get property for the x and y position of an
> object, the returned values are those of the objects center point, not
> it's top left corner --> unless of course you have moved the
> center point of the object to the top left corner of the
> object (or the
> other way around - hope that's clear - don't know how else to
> explain this).
> If you have a MC in another MC, the position of the movieclip
> will be in reference of it's parent movieclip and not the main
> timeline. You can use globalToLocal() to 'convert' it's x and
> y coordinates in reference to the _root and localToGlobal() does the
> opposite.
> Look up MovieClip.loacalToGlobal() and
> MovieClip.globalToLocal() in the Actionscript dictionary for
> more on that.



[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]