Hi Guys,
I’m having a little difficulty getting to grips with the getBounds() Movie Clip function. I assumed the getbounds() method simply got the boundary coordinates for the movie Clip, that one could use to draw a rectangle. This is what I’m trying to do;I’m trying to get a movie clips coordinate bounds, and use the min and max values of x and y to draw rectangle around the object. Simple right? But in my case, I’m getting some unexpected results. I wonder does ther registration point of the object determine the coordinate values? Also are the coordinate values local to the clip instance or global to the stage?
Below is the code exert:
// Global Movie Clip variable
// Holds the returned rect bounds
var edit:MovieClip;
Square2_mc.onPress = function() {
edit = showBounds(this);
}
Square2_mc.onRollOut = function() {
Square2_mc.onMouseDown = function() {
hideBounds(edit);
}
}
// Function shows MovieClip bounds
function showBounds(inputMC:MovieClip):MovieClip {
var mc:MovieClip = inputMC;
var bounds:Object = mc.getBounds(this);
//
// Draw our rectangle
this.createEmptyMovieClip("bounds_mc", this.getNextHighestDepth());
bounds_mc._x = mc._x;
bounds_mc._y = mc._y;
bounds_mc.lineStyle(1, 0xFF9900, 100);
bounds_mc.moveTo(0, 0);
bounds_mc.lineTo(bounds.xMin, 0);
bounds_mc.lineTo(bounds.xMin, bounds.YMax);
bounds_mc.lineTo(bounds.xMax,bounds.yMin);
bounds_mc.lineTo(0, 0);
bounds_mc.endFill();
return bounds_mc;
}
// Function hides MovieClip bounds
function hideBounds(inputMC:MovieClip) {
var mc:MovieClip = inputMC;
mc.removeMovieClip();
}
Many thanks
TAJ
P.S. I am very appreciative of all the support and advice from you guys. As a novice, starting out can be a little confusing.