User Guide

MovieClip 869
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