# Help with code: onPress works but onRelease doesnt!?!

**URL:** <https://forum.kirupa.com/t/help-with-code-onpress-works-but-onrelease-doesnt/221908>\
**Category:** flash\
**Created:** [April 9, 2007, 10:02am UTC](https://forum.kirupa.com/t/help-with-code-onpress-works-but-onrelease-doesnt/221908 "2007-04-09T10:02:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![iceblueflame](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@iceblueflame](https://forum.kirupa.com/u/iceblueflame)\
**Post date:** [April 9, 2007, 10:02am UTC](https://forum.kirupa.com/t/help-with-code-onpress-works-but-onrelease-doesnt/221908/1 "2007-04-09T10:02:26Z")

</div>

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();  
}
