If you test this with the correct instance names in AS3, you'll notice the player shakes about if one of it's co-ordinates fall in line and also once it gets to it's target location.
Script, notes are below to explain what's going on:
//--OUTLINE MOVE--//
stage.addEventListener( MouseEvent.CLICK, placeOutline );
function placeOutline( evt:Event ):void {
var z2 = mouseX;
var r2 = mouseY;
outline.x = z2;
outline.y = r2;
}
//END
//--RE-ROTATE--//
stage.addEventListener( Event.ENTER_FRAME, rotatePlayer2 );
function rotatePlayer2( evt:Event ):void {
var z3 = mouseX-player.x;
var r3 = mouseY-player.y;
var e3 = z3/r3;
var k3 = Math.atan (e3);
var g3 = k3*180/Math.PI;
var rotationplayer = g3 -=90;
if (mouseY>player.y) {
player.rotation = 90 - g3;
} else if (mouseYplayer.rotation=180-(g3-90);
}
}
//END
//--AUTOMOVE--//
stage.addEventListener( Event.ENTER_FRAME, movePlayer );
function movePlayer( evt:Event ):void {
var speed2 = 3;
var x1 = player.x;
var y1 = player.y;
var x2 = outline.x;
var y2 = outline.y;
if (x1>x2) {
player.x -= speed2;
} else {
if (x1player.x += speed2;
}
}
if (y1>y2) {
player.y -= speed2;
} else {
if (y1player.y += speed2;
}
}
}
The player, instance 'player', is set to face the mouse, this works fine and after removing this, it isn't cause the problem.
Icon, instance 'outline' is moved by clicking the mouse to the location clicked on.
The player checks it's x and y co-ords to see if it's in the right place, if it isn't, it fixes them. This is where the shaking occures and I want to eliminate this.
Help appreciated or an explanation of why it's doing this also appreciated.