# Relative mouse position

**URL:** https://forum.kirupa.com/t/relative-mouse-position/287189
**Category:** Uncategorized
**Created:** [April 27, 2009, 8:23pm UTC](https://forum.kirupa.com/t/relative-mouse-position/287189 "2009-04-27T20:23:53Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![afraidofdark](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@afraidofdark](https://forum.kirupa.com/u/afraidofdark)
#### Post date: [April 27, 2009, 8:23pm UTC](https://forum.kirupa.com/t/relative-mouse-position/287189/1 "2009-04-27T20:23:53Z")

</div>

hello, I am tring to implement quake like movement (w-a-s-d and \_xmouse for z rotation), I have a problem, when my cursor exits from fla screen or it reachs the end of the screen, \_xmouse stop sending information about mouse position, I need a method to keep getting change amount of mouse position even if user’s cursor is out side of the fla, I would do this by setting mouse position to the center of the window but I cant do that in action script, what should I do ? here is my code

```auto
var relX:Number = 0;
var relY:Number = 0;
var oldX:Number = 0;
var oldY:Number = 0;

onMouseMove = function() {
    relX = _xmouse - oldX;
    relY = _ymouse - oldY;
    oldX = _xmouse;
    oldY = _ymouse;
    var ang:Number = relX*0.05; 
    direction.rotate(relX*0.05); // direction is my driection vector 
   a["b"]._rotation = direction.angle;
};

```
