PDA

View Full Version : [AS3] possible to keep mouse pointer within bounds?


pinworm
06-01-2007, 03:33 PM
Im really new to flash and actionscript, and im trying to make a simple game. Is it possible once the stage has focus to keep the mouse from leaving the stage, so that you cant click out of the stage? Obvoiusly there would be a way to release the mouse and I dont want to have to make the app full screen.

plutocrat
06-01-2007, 04:25 PM
mouseX and mouseY are read-only. This is a good thing, or advertisers would make our mouses move to their banners. This would suck.


The mouseX/mouseY values, however, will never be outside the stage bounds.

pinworm
06-01-2007, 04:57 PM
darn i figured that would be the case. the only other solution i can think of is to make a border around the game area(unused stage space) so that clicks will be picked up if the user moves the mouse too far out. it doesnt seem like a good solution though.

plutocrat
06-01-2007, 05:13 PM
This sounds of evil intent.

If a user has his mouse outside of the bounds, why would he want to affect your game?

Anyway, flash only detects actions within its focus.

pinworm
06-01-2007, 06:29 PM
yea i can see your perspective, but the game i have in mind has a lot of mouse movement and clicking and i dont want the user to be able to click outside the window and lose focus because that can be extremely annoying when ur playing. imagine playing a first person shooter in windowed mode where the mouse isnt bound to that window. your cursor would eventualy leave the screen and you would click your desktop or something else. its a similar situation to what im thinking of.

plutocrat
06-01-2007, 06:56 PM
Just make your window bigger and add a border. I am fairly sure there is no way to coe your way out of this.