Key and Mouse Events Flash Not working well together

Subscribe to Key and Mouse Events Flash Not working well together 9 posts

avatar for Jcupz Jcupz 12 posts
Flag Post

Messing around creating a little engine for my game I ran into an odd issue I can’t catch Mouse Events while holding a keyDown?? Even when releasing the key it takes a second for MouseEvents to be accepted again.

My key events will continue to fire even if I am holding one down but when it comes to Mouse it gets ignored D:

I guess I can just make it a key for the mouse Event but that sounds hindering. Has anyone else experienced this? and how did they get passed it?

Thank you!

 
avatar for Senekis93 Senekis93 4090 posts
Flag Post

Post the code. That shouldn’t happen.

 
avatar for Jcupz Jcupz 12 posts
Flag Post

OnAddedToStage:
stage.addEventListener(KeyboardEvent.KEY_DOWN, addKey);
stage.addEventListener(KeyboardEvent.KEY_UP, removeKey);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);

AddKey:
if (m_keys.indexOf(p_e.keyCode) == -1) {
m_keys.push(p_e.keyCode);
m_lastKey = p_e.keyCode;
m_game.notify(new KeyMessage(KEYPRESSED, p_e.keyCode, m_game));
trace("USER IS PRESSING KEY " + p_e.keyCode);
}

RemoveKey:
var l_index:int = m_keys.indexOf(p_e.keyCode);
if(l_index!=-1){
m_keys.splice(l_index, 1);
m_game.notify(new KeyMessage(KEYRELEASED, p_e.keyCode, m_game));
trace("USER RELEASED KEY " + p_e.keyCode);
}

onMouseDown:
m_game.notify(new PointMessage(MOUSEDOWN, p_e.stageX, p_e.stageY, m_game));
trace(“MOUSEDOWN EVENT CAUGHT”);


Yeah that’s my code. I am using the traces to see if the event fires and mouseDown trace wont happen while a key is pressed.
If there needs to be any explaining I can, but I’m pretty sure the traces will speak for itself.

Could it be a laptop thing?? Didn’t think of it actually being my computer.

 
avatar for Senekis93 Senekis93 4090 posts
Flag Post

That’s strange indeed.

I don’t know if it could be a laptop issue, but I doubt it’s related.
Nothing looks out of place there.

 
avatar for Jcupz Jcupz 12 posts
Flag Post

Seriously strange, I even removed the key listeners just to try and do mouse while holding a key and it didn’t work. I was wondering if like Key Events were spamming and blocking out MouseEvents but that can’t be the case..

 
avatar for Senekis93 Senekis93 4090 posts
Flag Post

Are you using CS?

I think it has some… keyboard shortcuts or something, make sure to disable them, otherway it may be doing weird things like selecting a tool from the program or something.

 
avatar for Jcupz Jcupz 12 posts
Flag Post

I am using Flash Develop :( But I could look into shortcuts causing the issue ha… But if I do a release build the swf it should work fine right?

 
avatar for Jcupz Jcupz 12 posts
Flag Post

OK well I have a crippled laptop went and took a mouse off another computer and the mouse events fire while using keys… Well thank you for looking over it all and helping. Made me realize it could be the hardware and it was.

Issue Fixed For future reference use a real mouse x.x and not the touch pad on a laptop.

 
avatar for BobTheCoolGuy BobTheCoolGuy 3755 posts
Flag Post
Originally posted by Jcupz:

OK well I have a crippled laptop went and took a mouse off another computer and the mouse events fire while using keys… Well thank you for looking over it all and helping. Made me realize it could be the hardware and it was.

Issue Fixed For future reference use a real mouse x.x and not the touch pad on a laptop.

Yup, on my laptop, the touchpad is disabled while you are typing (to prevent accidental touches from screwing things up)