my code is listed below. basically, i wrote this code to generate a rectangle that surrounds the movie clip called ‘SELECTED’ along with a small square that appears at the bottom left corner of the new rectangle.
this new rectangle + tiny square are supposed to act as resizing tool for the movie clip ‘SELECTED’. hence, if i press and drag the small square, the mc SELECTED should get resized accordingly. that is happening to some extent, except that when i release the mouse button, neither the onRelease nor onReleaseOutside function gets called.
onLoad = function()
{
pressed = false;
mulx = 1;
muly = 1;
}
onEnterFrame = function()
{
this.createEmptyMovieClip(“surround”,199);
drawRectangle(surround,SELECTED._width+5,SELECTED._height+5,0x00FF00,6);
surround._x = SELECTED._x;
surround._y = SELECTED._y;
surround.createEmptyMovieClip(“resizer”,198);
drawRectangle(surround.resizer,10,10,0x000000,100);
mulx = SELECTED._xscale / Math.abs(SELECTED._xscale);
muly = SELECTED._yscale / Math.abs(SELECTED._yscale);
surround.resizer._x = (surround._width/2)*mulx;// + surround._x;
surround.resizer._y = (surround._height/2)*muly;// + surround._y;
surround.resizer.onPress = function()
{
//trace(“done true”);
pressed = true;
oldx = surround._xmouse;
oldy = surround._ymouse;
}
surround.resizer.onRelease = function()
{
pressed = false;
}
surround.resizer.onReleaseOutside = function()
{
pressed = false;
}
if(pressed == true)
{
diffx = surround._xmouse - oldx;
diffy = surround._ymouse - oldy;
SELECTED._xscale += diffx;
SELECTED._yscale += diffy;
oldx = surround._xmouse;
oldy = surround._ymouse;
}
}
function drawRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, fillColor:Number, fillAlpha:Number):Void
{
target_mc.lineStyle(1,0x000000,100);
target_mc.beginFill(fillColor, fillAlpha);
target_mc.moveTo(-boxWidth/2, -boxHeight/2);
target_mc.lineTo(boxWidth/2, -boxHeight/2);
target_mc.lineTo(boxWidth/2, boxHeight/2);
target_mc.lineTo(-boxWidth/2, boxHeight/2);
target_mc.lineTo(-boxWidth/2, -boxheight/2);
target_mc.endFill();
}