# Can someone help me with precision movement

**URL:** <https://forum.kirupa.com/t/can-someone-help-me-with-precision-movement/312516>\
**Category:** flash\
**Created:** [August 5, 2010, 2:35pm UTC](https://forum.kirupa.com/t/can-someone-help-me-with-precision-movement/312516 "2010-08-05T14:35:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![m2244](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@m2244](https://forum.kirupa.com/u/m2244)\
**Post date:** [August 5, 2010, 2:35pm UTC](https://forum.kirupa.com/t/can-someone-help-me-with-precision-movement/312516/1 "2010-08-05T14:35:30Z")

</div>

I am down to about a hand full of hair on my head at this point.

The scenerio: I am trying to make a very simple flight simulator type of animation. When the user presses and holds an arrow key, things move/rotate.

The problem: If you alternate moving/rotating things in different directions, the location/rotation of these things becomes skewed. They seem to rotate or move more in one direction than another. For instance, if you play around with the animation for a while, the background is moved or rotated so far in one direction that you can eventually see the edge of the background movieclip. I have tried to tween these things back to the propper location but it just does not look good at all.

Can anyone please help me oput here?

```auto

import flash.display.MovieClip;
import flash.events.MouseEvent;
import com.greensock.TweenLite;
import com.greensock.easing.*;
 
var leftKey:Boolean = false;
var upKey:Boolean = false;
var rightKey:Boolean = false;
var downKey:Boolean = false;
var lrIncrementor:Number = .7;
var udIncrementor:Number = .7;
var rotateInc:Number = .005;
 
mcBeginMessage.btnContinue.addEventListener(MouseEvent.CLICK, handleBegin);

function handleBegin(evt:MouseEvent):void
{
 Mouse.hide();
 mcBeginMessage.x=-300;
 mcBeginMessage.btnContinue.removeEventListener(MouseEvent.CLICK, handleBegin);
 stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyPress);
 
}
function handleKeyPress(evt:KeyboardEvent):void
{
 stage.addEventListener(KeyboardEvent.KEY_UP, handleKeyRelease);
 stage.addEventListener(Event.ENTER_FRAME, handleMovingStuff);
 
 if(evt.keyCode == 37)
 {
  leftKey = true;
 }
 if(evt.keyCode == 38)
 {
  upKey = true;
 }
 if(evt.keyCode == 39)
 {
  rightKey = true;
 }
 if(evt.keyCode == 40)
 {
  downKey = true;
 }
}

function handleKeyRelease(evt:KeyboardEvent):void
{
 stage.removeEventListener(Event.ENTER_FRAME, handleMovingStuff);
 
 lrIncrementor = .7;
 udIncrementor = .7;
 rotateInc = .005;
 if(evt.keyCode == 37)
 {
  leftKey = false;
 }
 if(evt.keyCode == 38)
 {
  upKey = false;
 }
 if(evt.keyCode == 39)
 {
  rightKey = false;
 }
 if(evt.keyCode == 40)
 {
  downKey = false;
 }
}
function handleMovingStuff(evt:Event):void
{
 lrIncrementor += .05;
 udIncrementor += .05;
 rotateInc += .03;
 
 if(leftKey == true && mcVertLine.x > 390)
 {
  mcVertLine.x -= lrIncrementor;
  mcFront.rotation += lrIncrementor;
  mcBackGrnd.rotation += rotateInc;
 }
 if(upKey == true && mcHorizLine.y < 549)
 {
  mcHorizLine.y += udIncrementor;
  mcSide.rotation -= udIncrementor/2;
  mcBackGrnd.y -= 5;
 }
 if(rightKey == true && mcVertLine.x < 503)
 {
  mcVertLine.x += lrIncrementor;
  mcFront.rotation -= lrIncrementor;
  mcBackGrnd.rotation -= rotateInc;
 }
 if(downKey == true && mcHorizLine.y > 436)
 {
  mcHorizLine.y -= udIncrementor;
  mcSide.rotation += udIncrementor/2;
  mcBackGrnd.y += 5;
 }
 
 if(mcVertLine.x >= 447 && mcVertLine.x <= 448)
 {
  TweenLite.to(mcBackGrnd, 1,{rotation:24});
 }
 
}

```
