Name
MovieClip.localToGlobal( ) Method — convert a point in a clip to main Stage coordinates
Availability
Flash 5
Synopsis
mc.localToGlobal(point)
Arguments
- point
A reference to an object with two properties,
x
andy
, that describe a point inmc
’s coordinate space. Bothx
andy
may be any floating-point number.
Description
The localToGlobal( )
method converts the
x
and y
properties of
point
from coordinates given in
mc
’s coordinate space to
coordinates on the main Stage of the Player. Note that
localToGlobal( )
does not return a new object,
it merely modifies the existing x
and
y
values of point
.
To use localToGlobal( )
, we must first create a
so-called point or
coordinates object with x
and
y
properties. To do so, we’ll simply create
a generic object from the Object class, and add
x
and y
properties to it:
myPoint = new Object( ); myPoint.x = 10; myPoint.y = 20;
The x
and y
properties of our
object are positions on the horizontal and vertical axes of
mc
, relative to mc
’s registration point (shown as a crosshair in
mc
’s Library symbol). For example,
an x
of 10 is 10 pixels to the right of
mc
’s registration point, and a
y
of 20 is 20 pixels below mc
’s registration point. With our object created
and our x
and y
properties set,
we then pass the object to the localToGlobal( )
method, as in:
myClip.localToGlobal(myPoint);
When localToGlobal( )
is executed, the values of
myPoint
’s x
and
y
properties are transformed to represent the corresponding point on the main Stage, measured from the Stage’s ...
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.