# Drag and Rotate + Condition

**URL:** <https://forum.kirupa.com/t/drag-and-rotate-condition/306445>\
**Category:** flash\
**Created:** [March 15, 2010, 5:46pm UTC](https://forum.kirupa.com/t/drag-and-rotate-condition/306445 "2010-03-15T17:46:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alemieux34](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@alemieux34](https://forum.kirupa.com/u/alemieux34)\
**Post date:** [March 15, 2010, 5:46pm UTC](https://forum.kirupa.com/t/drag-and-rotate-condition/306445/1 "2010-03-15T17:46:13Z")

</div>

I’m trying to create a script that would imitate an old rotary phone dial. I have this script, but need it to function on MOUSE\_DOWN:

```auto
handle.addEventListener(MouseEvent.ENTER_FRAME, startRotate);

function startRotate(e:Event):void {
    var dx:Number=mouseX-handle.x;
    var dy:Number=mouseY-handle.y;
    // presupposes position of object to be facing to the right. 
    var radians:Number=Math.atan2(dy,dx);
    handle.rotation=radians*180/Math.PI;
    var hR:Number = Math.round(handle.rotation);
    rotationA.text = String(hR);
}

```

Changing the event handler doesn’t work. Somehow the MouseDown function should be working like an EnterFrame event, I guess.

The condition I want to check is whether or not the handle is at a certain degree angle to stop the dial from rotating.

if (handle.rotation \>= 30) {  
handle.rotation = ?;  
}

Not sure what I need to put in there to stop it from rotating. Any guesses? :stormtrooper:
