Hi Guys,
I’m having some difficulty in getting two movie clips to move together at the same time. Basically, I’ve created a function called showSelect(), which shows an object’s bounds using the getbounds() and lineTo() methods, when you click on the object on stage. However, I also want these bounds to be shown when the object is being dragged across the stage. Unfortunately, when this happens the bounds don’t appear to be overlapping the object as it should do.
If anybody can help me with some suggestions, or some tweaking of code, it would be very much appreciated. Please find below an exert of my code and copy of the source file attached:
var bounds:MovieClip;
Square_mc.onPress = function() {
bounds = showSelect(this);
}
Square_mc.onRelease = function() {
hideSelect(bounds);
}
// Function shows MovieClip bounds
function showSelect(inputMC:MovieClip):MovieClip {
var mc:MovieClip = inputMC;
var bounds:Object = mc.getBounds(this);
//
// Draw our rectangle
this.createEmptyMovieClip("bounds_mc", this.getNextHighestDepth());
bounds_mc.lineStyle(2, 0xFF9900, 100);
/*trace("this is " + this);
trace("mc._width is " + mc._width);
trace("mc._height is " + mc._height);
trace('xmin is ' + bounds.xMin);
trace('xmax is ' + bounds.xMax);
trace('ymin is ' + bounds.yMin);
trace('ymax is ' + bounds.yMax);*/
bounds_mc.moveTo(bounds.xMin, bounds.yMin);
bounds_mc.lineTo(bounds.xMin, bounds.yMax);
bounds_mc.lineTo(bounds.xMax, bounds.yMax);
bounds_mc.lineTo(bounds.xMax, bounds.yMin);
bounds_mc.lineTo(bounds.xMin, bounds.yMin);
bounds_mc.endFill();
mc.startDrag();
this.onMouseMove = function() {
bounds_mc._x = this._xmouse;
bounds_mc._y = this._ymouse;
}
return bounds_mc;
}
function hideSelect(inputMC:MovieClip):Void {
var boundsMC:MovieClip = inputMC;
//
boundsMC.removeMovieClip();
}
Many Thanks
TAJ