PDA

View Full Version : raw mouse data


daLavaTroll
09-19-2007, 05:04 AM
Hello. I was wondering if I can get more data from the mouse other than xmouse/ymouse. I just upgraded to AS3. I don't know much about it. Basically I have this game that needs data from the mouse even when the pointer is off of the flash stage. It's a game like centipede. So I'm kind of trying to emulate a roller ball. To the best of my knowledge, this would have to be done by creating another active X control. I'm just starting to get into C++. Most of my experience is with AS2. I love Flash and would prefer it as my delivery method, but if I can't get continuous mouse data, it's a no go. Is there a way?

plutocrat
09-19-2007, 06:26 AM
Unfortunately, mouseX and mouseY are read-only (i.e. you cannot force them to stay on the stage, which is what you are effectively asking). Imagine if this were not the case; annoying banner ads would steal your mouse. They are bad enough already when they start talking at you.

NOT THAT THIS SITE WOULD STOOP TO ACCEPTING NOISY BANNER ADS.

</rant>

dr_zeus
09-19-2007, 05:08 PM
you cannot force them to stay on the stage, which is what you are effectively asking

That wasn't the question at all. The question was whether you can continue to receive position data even if the mouse is OFF the stage.


daLavaTroll, there's one interesting way to do it that I know about.

var tf:TextField = new TextField();
this.addChild(tf);

this.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

function mouseMoveHandler(event:MouseEvent):void
{
tf.text = this.stage.mouseX + "," + this.stage.mouseY;
}

Put the code above into a new FLA file. Try clicking on the stage and dragging your mouse outside the bounds of the SWF. You'll notice that the TextField will continue to update until you release your mouse, even if you aren't within the Flash Player instance anymore.

Again, the mouse button must be held down or no MOUSE_MOVE event will be fired outside the bounds of the stage.

daLavaTroll
09-20-2007, 04:39 AM
That's a very interesting piece of code. It's still screen coordinates though. It amazes me that about half the people I talk to about this don't understand why I need this. The mushroom in the centipede game can block your movement. Your mouse keeps on moving, moving past the flash stage, off the browser and to the end of your screen, but your guy stays right next to the mushroom until you move around it.