getRect (MovieClip.getRect method)

public getRect(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, excluding any strokes on shapes. The values that getRect() returns are the same or smaller than those returned by MovieClip.getBounds().

Note: Use MovieClip.localToGlobal() and MovieClip.globalToLocal() methods 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.

Availability: ActionScript 1.0; Flash Player 8

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 and draws inside of it a square with a stroke width of 4 pixels. The example then calls both the MovieClip.getBounds() and MovieClip.getRect() methods to show the difference between the two. The getBounds() method returns the minimum and maximum coordinate values of the entire movie clip, including the stroke width of the square. The getRect() method returns the minimum and maximum coordinate values excluding the stroke width of 4 pixels.

this.createEmptyMovieClip("square_mc", 1);
square_mc._x = 10;
square_mc._y = 10;
square_mc.beginFill(0xFF0000);
square_mc.lineStyle(4, 0xFF00FF, 100, true, "none", "round", "miter", 1);
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);
trace("getBounds() output:");
for (var i in bounds_obj) {
    trace(i+" --> "+bounds_obj[i]);
}

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

The trace() statement results in the following output.

 getBounds() output:
 yMax --> 112
 yMin --> 8
 xMax --> 112
 xMin --> 8
 getRect() output:
 yMax --> 110
 yMin --> 10
 xMax --> 110
 xMin --> 10

See also

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