Quick and dirty code to have the arrow point back at the center of the stage.
package com.drpunchlogic
{
// display
import flash.display.MovieClip;
import flash.display.Stage;
// events
import flash.events.MouseEvent;
import flash.events.Event;
// geom
import flash.geom.Point;
//ui
import flash.ui.Mouse;
public class mouseArrow extends MovieClip
{
private var _stage:Stage;
private var _temp:Point = new Point();
private var _x:Number;
private var _y:Number;
private var _rot:Number;
public function mouseArrow() : void
{
trace( "[ ARROW ]" );
Mouse.hide(); //hide mouse
mouseEnabled = true;
}
public function init( _stage:Stage, sw:Number, sh:Number ) : void
{
this._stage = _stage;
_x = _stage.mouseX;
_y = _stage.mouseY;
_stage.addEventListener( MouseEvent.MOUSE_MOVE, moveMe );
}
private function moveMe( e:MouseEvent ) : void
{
_x = _stage.mouseX;
_y = _stage.mouseY;
_rot = Math.atan2( _y - _temp.y, _x - _temp.x) * 180 / Math.PI;
if (_rot - rotation > 180)
{
_rot -= 360;
} else if (rotation - _rot > 180) {
_rot += 360;
}
rotation -= (rotation - _rot) / 10;
x = _temp.x = _x;
y = _temp.y = _y;
e.updateAfterEvent();
}
}
}
[ download ]

Post a Comment