Works for me. You can even leave the MOUSE_MOVE
event on and it works during tweens.
import flash.display.Sprite;
import fl.transitions.Tween;
import fl.transitions.easing.*;
addEventListener(Event.ENTER_FRAME, loaderCheck);
function loaderCheck(e:Event):void {
// Make sure we have a populated loader by referencing one of its properties.
var answer:Boolean;
try { answer = (this.loaderInfo.width > 0) ? true : false;} catch (e:Error) {}
if (answer == true) {
removeEventListener(Event.ENTER_FRAME, loaderCheck);
createCircle()
}
}
var circle:Sprite;
function createCircle():void {
circle = new Sprite();
circle.graphics.beginFill(0xFF0000);
circle.graphics.drawCircle(0, 0, 30);
circle.graphics.drawRect(0, -30, 2, 30);
circle.graphics.endFill();
addChild(circle);
circle.x = loaderInfo.width/2;
circle.y = loaderInfo.height/2;
stage.addEventListener(MouseEvent.MOUSE_MOVE, followTheMouse);
circle.addEventListener(MouseEvent.MOUSE_UP, enterZone);
}
function followTheMouse(e:MouseEvent):void {
circle.rotation = Math.atan2(mouseY-circle.y, mouseX-circle.x)*180 / Math.PI + 90;
}
function enterZone(e:MouseEvent):void {
//stage.removeEventListener(MouseEvent.MOUSE_MOVE, followTheMouse);
var myTween:Tween = new Tween(circle, "x", Elastic.easeOut, 0, 300, 3, true);
}