i have a square sprite that i want to be draggable onPress, and nondraggable when the control but is pressed? also rotatable when control is pressed. help please....
box_mc.onPress = function() {
// if the CTRL key is down, rotate the clip
if (Key.isDown(Key.CONTROL)) {
// calculate the offset angle necessary to avoid "jumping"
xdiff = _root._xmouse-box_mc._x;
ydiff = _root._ymouse-box_mc._y;
offset = Math.atan2(ydiff, xdiff)*180/Math.PI-this._rotation;
// set the sprite enterframe event for regular processing
this.onEnterFrame = function() {
// make the sprite point at the mouse
xdiff = _root._xmouse-box_mc._x;
ydiff = _root._ymouse-box_mc._y;
angle = Math.atan2(ydiff, xdiff)*180/Math.PI;
// use the offset angle to avoid "jumping"
box_mc._rotation = angle-offset;
}
// if the CTRL key is up, drag the clip
} else {
this.startDrag (false);
}
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.