Flash Lite 2.x and 3.0 ActionScript Language Reference

getBounds (MovieClip.getBounds method)

public getBounds(bounds:Object) : Object

Returns properties that are the minimum and maximum x and y coordinate values of the movie clip, based on the bounds parameter.

Note: Use MovieClip.lcalToGlobal() and MovieClip.globalToLocal() to convert the movie clip's local coordinates to Stage coordinates, or Stage coordinates to local coordinates, respectively.

You can extend the methods and event handlers of the MovieClip class by creating a subclass.

Parameters

bounds:Object - The target path of the Timeline whose coordinate system you want to use as a reference point.

Returns

Object - An object with the properties xMin, xMax, yMin, and yMax.

Example

The following example creates a movie clip called square_mc. The code draws a square for that movie clip and uses MovieClip.getBounds() to display the coordinate values of the instance in the Output panel.

this.createEmptyMovieClip("square_mc", 1);
square_mc._x = 10;
square_mc._y = 10;
square_mc.beginFill(0xFF0000);
square_mc.moveTo(0, 0);
square_mc.lineTo(100, 0);
square_mc.lineTo(100, 100);
square_mc.lineTo(0, 100);
square_mc.lineTo(0, 0);
square_mc.endFill();

var bounds_obj:Object = square_mc.getBounds(this);
for (var i in bounds_obj) {
    trace(i+" --> "+bounds_obj[i]);
}

The following information appears in the Output panel:

yMax --> 110
yMin --> 10
xMax --> 110
xMin --> 10

See also

globalToLocal (MovieClip.globalToLocal method), localToGlobal (MovieClip.localToGlobal method)