I was wondering if it is possible to have my flash game determine the position of the mouse, even when the cursor is not inside the stage.
My movie clip should move horizontally between x = 100
and 500
, using mouseX
for movement:
private var previousX : int;
private var mc : MovieClip;
//...
private function update(e:Event = null):void
{
var deltaX : int = (mouseX - previousX) / 2;
mc.x = Math.min(Math.max(mc.x + deltaX, 100), 500);
previousX = mouseX;
}
The above code works fine, as long as the cursor is above my flash game. When the cursor is outside the stage, mouseX
stops updating. I realise that mouseX
is probably not what I'm looking for, so I was wondering if there was any other way of finding the cursors position.
I hoped there was a way to set the mouse position directly, so I could center it after every update, so it would almost never be able to leave the frame in the first place. Is that possible?