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.getRect()
method returns the minimum and maximum coordinate values of the entire movie clip,
including the stroke width of the square. The
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
statement results in the following output.
trace()
getBounds() output:
yMax --> 112
yMin --> 8
xMax --> 112
xMin --> 8
getRect() output:
yMax --> 110
yMin --> 10
xMax --> 110
xMin --> 10
MovieClip.getBounds()
methods to show the difference between the two. The
method returns the minimum and
getRect()
and
getBounds()
MovieClip
869
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?