Есть объект с пушкой, пушка должна поворачиваться за курсором, я добился того, что пушка реагирует на курсор - а дальше не могу, помогите пожалуйста. Вот код:

Код AS3:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.utils.Timer;
public class Hero extends MovieClip
{
//ОБЪЕКТ КОТОРЫЙ БУДЕТ ДВИГАТЬСЯ
private var player:MovieClip;
private var playerSpeed:Number = 8;
// ФЛАГИ НАПРАВЛЕНИЯ ДВИЖЕНИЯ
private var movingUp:Boolean = false;
private var movingDown:Boolean = false;
private var movingLeft:Boolean = false;
private var movingRight:Boolean = false;
private var rotateSpeedMax:Number = 20;
private var dx:Number;
private var dy:Number;
private var pcos:Number;
private var psin:Number;
private var trueRotation:Number;
public function Hero():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
player = new Player1();
player.x = 100;
player.y = 100;
addChild(player);
stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
stage.addEventListener(Event.ENTER_FRAME, updateRotation);
stage.addEventListener(KeyboardEvent.KEY_DOWN, myOnPress);
stage.addEventListener(KeyboardEvent.KEY_UP, myOnRelease);
}
private function updateRotation(e:Event):void
{
// РАСЧЕТ ВРАЩЕНИЯ ПУШКИ
dx = player.x - stage.mouseX;
dy = player.y - stage.mouseY;
// В КАКУЮ СТОРОНУ ПОВОРАЧИВАТЬ
var rotateTo:Number = getDegrees(getRadians(dx, dy));
// ПОВОРАЧИВАТЬ ОТ 0 ДО 360 ГРАД
if (rotateTo > player.gun.rotation + 180) rotateTo -= 360;
if (rotateTo < player.gun.rotation - 180) rotateTo += 360;
// ЛЕГКОСТЬ ВРАЩЕНИЯ
trueRotation = (rotateTo - player.gun.rotation) /rotateSpeedMax;
player.gun.rotation += trueRotation;
}
public function getRadians(delta_x:Number, delta_y:Number):Number
{
var r:Number = Math.atan2(delta_y, delta_x);
if (delta_y < 0)
{
r += (2 * Math.PI);
}
return r;
}
public function getDegrees(radians:Number):Number
{
return Math.floor(radians/(Math.PI/180));
}
private function enterFrameHandler(event:Event):void
{
var i:int = 0;
// ПЕРЕДВИЖЕНИЕ
if ( movingLeft && !movingRight )
{
player.x -= playerSpeed;
player.rotation = 270;
// player.angle = 180;
}
if ( movingRight && !movingLeft )
{
player.x += playerSpeed;
player.rotation = 90;
// player.angle = 0;
}
if ( movingUp && !movingDown )
{
player.y -= playerSpeed;
player.rotation = 0;
// player.angle = -90;
}
if ( movingDown && !movingUp )
{
player.y += playerSpeed;
player.rotation = 180;
// player.angle = 90;
}
}
public function myOnPress(event:KeyboardEvent):void
{
switch( event.keyCode )
{
case Keyboard.UP:
movingUp = true;
movingDown = false;
movingLeft = false;
movingRight = false;
break;
case Keyboard.DOWN:
movingUp = false;
movingDown = true;
movingLeft = false;
movingRight = false;
break;
case Keyboard.LEFT:
movingUp = false;
movingDown = false;
movingLeft = true;
movingRight = false;
break;
case Keyboard.RIGHT:
movingUp = false;
movingDown = false;
movingLeft = false;
movingRight = true;
break;
case 87:
movingUp = true;
movingDown = false;
movingLeft = false;
movingRight = false;
break;
case 83:
movingUp = false;
movingDown = true;
movingLeft = false;
movingRight = false;
break;
case 65:
movingUp = false;
movingDown = false;
movingLeft = true;
movingRight = false;
break;
case 68:
movingUp = false;
movingDown = false;
movingLeft = false;
movingRight = true;
break;
}
}
public function myOnRelease(event:KeyboardEvent):void
{
switch( event.keyCode )
{
case Keyboard.UP:
movingUp = false;
break;
case Keyboard.DOWN:
movingDown = false;
break;
case Keyboard.LEFT:
movingLeft = false;
break;
case Keyboard.RIGHT:
movingRight = false;
break;
case 87:
movingUp = false;
break;
case 83:
movingDown = false;
break;
case 65:
movingLeft = false;
break;
case 68:
movingRight = false;
break;
}
}
}
}