localToGlobal()
Top  Previous  Next


SWiSH Player Support
SWF5 or later - Supported Internally

Syntax
mySprite.localToGlobal(point);

Arguments
point: The name or identifier of an object specifying coordinates as properties.

Returns
Nothing.

Description
Method; converts the point object from the main Sprite coordinates (local) into the Stage coordinates (global).

Sample
This sample shows the local and global X/Y position of a shape named "shape1" inside the sprite named "thisSprite"

onEnterFrame() {
    location = new Object();
    location.x = thisSprite.shape1._X;
    location.Y = thisSprite.shape1._Y;
    thisSprite.localToGlobal(location);
    trace("Shape1's Local X location is: " add thisSprite.shape1._X);
    trace("Shape1's Local Y location is: " add thisSprite.shape1._Y);
    trace("Shape1's Global X location is: " add location.x);
    trace("Shape1's Global Y location is: " add location.y);
}

The local X/Y coordinates will never change - but if this sprite is being dragged by the mouse, the global X and Y coordinates will update as the position of the sprite changes in relation to the stage.