# Rotation cw and ccw

**URL:** <https://forum.kirupa.com/t/rotation-cw-and-ccw/319377>\
**Category:** Uncategorized\
**Created:** [February 18, 2011, 7:15am UTC](https://forum.kirupa.com/t/rotation-cw-and-ccw/319377 "2011-02-18T07:15:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meghana](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@Meghana](https://forum.kirupa.com/u/Meghana)\
**Post date:** [February 18, 2011, 7:15am UTC](https://forum.kirupa.com/t/rotation-cw-and-ccw/319377/1 "2011-02-18T07:15:50Z")

</div>

just able rotate wheel Clip. how to identify clockwise or anticlockwise rotation…

here try to rotate on mouse move direction. not just (wheel\_mc.rotation=20; )

i just want to rotate that wheel clockwise on mouse down … then what to do ?

add code

var angle:int=0;  
var theX:int=0;  
var theY:int=0;  
var speed:int=0;

var reverse:Boolean=false;  
function init():void {  
wheel\_mc.addEventListener(MouseEvent.MOUSE\_DOWN, onClick);  
wheel\_mc.addEventListener(MouseEvent.MOUSE\_UP,onUp);  
}  
function onArrowClick(event:MouseEvent):void {

```
wheel_mc.addEventListener(Event.ENTER_FRAME,rotate);

```

}  
function onClick(event:MouseEvent):void {  
wheel\_mc.removeEventListener(MouseEvent.MOUSE\_DOWN, onClick);  
wheel\_mc.addEventListener(Event.ENTER\_FRAME,rotate);  
}

function onUp(event:MouseEvent):void {  
wheel\_mc.removeEventListener(Event.ENTER\_FRAME,rotate);  
wheel\_mc.removeEventListener(MouseEvent.MOUSE\_UP,onUp);  
this.init();  
}

function rotate(e:Event) {

```
this.theX=mouseX-wheel_mc.x;
this.theY = (mouseY - wheel_mc.y) * -1;
this.angle =int( Math.atan(theY/theX)/(Math.PI/180));

if (theX&lt;0) {

	angle+=180;

}
if (theX&gt;=0&&theY&lt;0) {
	angle+=360;

}
angle_txt.text=String(angle);

wheel_mc.rotation = (angle*-1) + 90;

trace("angle &gt;&gt; ",angle);

```

}  
this.init();
