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<0) {
angle+=180;
}
if (theX>=0&&theY<0) {
angle+=360;
}
angle_txt.text=String(angle);
wheel_mc.rotation = (angle*-1) + 90;
trace("angle >> ",angle);
}
this.init();