# Why is this Mouse\_Move not working well?

**URL:** <https://forum.kirupa.com/t/why-is-this-mouse-move-not-working-well/312398>\
**Category:** flash\
**Created:** [August 2, 2010, 2:54pm UTC](https://forum.kirupa.com/t/why-is-this-mouse-move-not-working-well/312398 "2010-08-02T14:54:23Z")\
**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 2, 2010, 2:54pm UTC](https://forum.kirupa.com/t/why-is-this-mouse-move-not-working-well/312398/1 "2010-08-02T14:54:23Z")

</div>

When I move the mouse up, down, or left everything seems to track fine. But if I move the mouse right it gets very choppy and some of the movement seems not to be “recorded” to the variables. This is very frustrating. Has anyone ever seen this before?

```auto

var lastPointX:Number;
var lastPointY:Number;
var thisPointY:Number;
var thisPointX:Number;
var diffY:Number;
var diffX:Number;
var percentY:Number;
var percentX:Number;
// These variables make it possible to move the 2 indicator lines at author time, automatically setting the limits.
var leftLimit:Number = mcVertLine.x - 57;
var rightLimit:Number = mcVertLine.x + 57;
var topLimit:Number = mcHorizLine.y - 57;
var botLimit:Number = mcHorizLine.y + 57;

mcBeginMessage.btnContinue.addEventListener(MouseEvent.CLICK, handleBegin);

function handleBegin(evt:MouseEvent):void
{
 Mouse.hide();
 mcStick.startDrag(true);
 lastPointX = mouseX;
 lastPointY = mouseY;
 mcBeginMessage.x = -300;
 mcBeginMessage.btnContinue.removeEventListener(MouseEvent.CLICK, handleBegin);
 mcHitArea.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseLocation);
}

function handleMouseLocation(evt:Event):void
{
 thisPointY = mouseY;
 thisPointX = mouseX;
 diffY = thisPointY - lastPointY;
 diffX = (thisPointX - lastPointX);
 percentX = (diffX / thisPointX) * 6;
 percentY = (diffY / thisPointY) * 6;
 mcBackGrnd.rotation += percentX;
 mcBackGrnd.y+=percentY;
 mcFront.rotation += (percentX)*8;
 mcSide.rotation += (percentY)*2;
 //trace(percentY);
 if ((mcHorizLine.y - diffY) > topLimit && (mcHorizLine.y - diffY)< botLimit)
 {
  mcHorizLine.y=mcHorizLine.y-diffY;
  //trace("y = "+mouseY);
 }
 if ((mcVertLine.x - diffX) > leftLimit && (mcVertLine.x - diffX)< rightLimit)
 {
  mcVertLine.x=mcVertLine.x-diffX;
  //trace("x = "+mouseX);
 }
 lastPointY=thisPointY;
 lastPointX=thisPointX;
}

```
