PDA

View Full Version : MOUSE_MOVE preventing MOUSE_UP


tdsm
08-20-2008, 03:17 PM
Hi guys,

This is becoming a real issue for me... I am developing a small drawing application for a machine with next to no RAM and slow processor.

Here's a stripped down version of the code so you can see what I mean;


function doDraw(e:MouseEvent):void {
graphics.lineTo(mouseX,mouseY);
e.updateAfterEvent();
}

function stopDraw(e:MouseEvent):void {
trace("end drawing");
stage.removeEventListener(MouseEvent.MOUSE_MOVE,do Draw);
}

function startDraw(e:MouseEvent):void {
graphics.moveTo(mouseX,mouseY);
stage.addEventListener(MouseEvent.MOUSE_MOVE,doDra w,false,0,true);
}

graphics.lineStyle(1,0x000000);
stage.addEventListener(MouseEvent.MOUSE_UP,stopDra w,false,0,true);
stage.addEventListener(MouseEvent.MOUSE_DOWN,start Draw,false,0,true);


When the user presses the mouse button, a MOUSE_MOVE event listener is added which draws to the stage. A MOUSE_UP event removes the move listener. This all works as expected on my development machine, but on the slooooooow machine, it seems as if the MOUSE_MOVE event is blocking the MOUSE_UP from firing, so unless I stop moving my mouse, it continues to draw even when my mouse is up.

Even the buttonDown test returns true! The stopDraw function finally gets called when I stop moving the mouse and the mouse button is not down.

I even tried setting priorities when adding event listeners but this does not work either.

senocular
08-20-2008, 03:42 PM
is it really blocking or is it taking a while to catch up?

tdsm
08-20-2008, 04:29 PM
Ahhh, so when I move the mouse fast, it's adding lots of MOUSE_MOVE events to an event queue (maybe)... then calling the doDraw function untill the MOUSE_UP event gets to the front of the queue.

So does the MouseEvent.buttonDown property just tell me the button state when the event fired or can I find out the current state of the mouse button without waiting for the MOUSE_UP event?

senocular
08-20-2008, 04:37 PM
Ahhh, so when I move the mouse fast, it's adding lots of MOUSE_MOVE events to an event queue (maybe)... then calling the doDraw function untill the MOUSE_UP event gets to the front of the queue.

Yeah basically.

So does the MouseEvent.buttonDown property just tell me the button state when the event fired or can I find out the current state of the mouse button without waiting for the MOUSE_UP event?

I'm not 100% sure, but I'd place my bets that it would relate to the MOUSE_UP timing.

tdsm
08-21-2008, 09:12 AM
I spent ages trying to stop the events or working around them, but realised that all I'm doing is adding new instructions to the end of the 'queue' which don't get executed until the events I am trying to prevent, have executed.

I guess there would have to be something in the Event class that forced the event to be handled immediately and effectively 'jump the queue'.

Am I going to have to give up on this?

senocular
08-21-2008, 11:58 AM
If your client machine is so slow that it can't keep up, there's not much you can do... except get a faster one
; )

... actually, using ENTER_FRAME rather than MOUSE_MOVE would probably help, since that would be on "Flash's watch" rather than the system's.

tdsm
08-21-2008, 12:07 PM
Thanks mate,

Not the answer I was hoping for but at least I won't spend any more time trying to fix something that "ain't broke"! Thanks for the advice.

Tom