FatedToAsk
08-24-2009, 04:32 AM
package fated.mouse{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Stage;
public class ClipRotate{
private var _clip:MovieClip;
private var _stage:Stage;
public function ClipRotate(clip:MovieClip, stage:Stage) {
_clip=clip;
_stage=stage;
_stage.addEventListener(MouseEvent.MOUSE_MOVE, rotate);
}
private function rotate(event:MouseEvent) {
var X:int = _clip.mouseX;
var Y:int = _clip.mouseY;
var angle:Number = Math.atan2(Y,X)/(Math.PI/180);
trace("X: " + X + " Y: " + Y + " Angle: " + angle);
_clip.rotation=angle;
}
}
}
It appears that _clip.mouseX/Y seem to change quite dramatically between pixels, and seems to almost go in the polar opposites. (_clip.mouseX will be at 100 more example, but after moving just a smidgen, a pixel or two than it jumps all the way to around -100)
What is the problem with this code that my friend and I are experiencing? Any suggestions?
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Stage;
public class ClipRotate{
private var _clip:MovieClip;
private var _stage:Stage;
public function ClipRotate(clip:MovieClip, stage:Stage) {
_clip=clip;
_stage=stage;
_stage.addEventListener(MouseEvent.MOUSE_MOVE, rotate);
}
private function rotate(event:MouseEvent) {
var X:int = _clip.mouseX;
var Y:int = _clip.mouseY;
var angle:Number = Math.atan2(Y,X)/(Math.PI/180);
trace("X: " + X + " Y: " + Y + " Angle: " + angle);
_clip.rotation=angle;
}
}
}
It appears that _clip.mouseX/Y seem to change quite dramatically between pixels, and seems to almost go in the polar opposites. (_clip.mouseX will be at 100 more example, but after moving just a smidgen, a pixel or two than it jumps all the way to around -100)
What is the problem with this code that my friend and I are experiencing? Any suggestions?