Hi,
I’have a 2 in 1 problem Would you please give me some help?
The facts:
- In this example, when the user press on 1, 2, 3, 4 or 5 on the keypad, the corresponding pushbutton should display a “down” state.
This should last a couple frames so that the user has some time to see it displayed on stage. - The user should be able to press on 1 button, hold it, and press on a second one
This should be displayed on stage! One must see the first button pressed…followed by the second one (so, 2 buttons pressed consecutively!)
The problems:
- I’m now using a couple frames in the timeline of each button to make the “state down” last a little.
Is there a better way to do it (a “timer” function?) - I can’t get the multiple keypress detection work!
If I press simultaneously it’s working…
but if I press 1 button, hold it 1 sec, then (without releasing the 1st one) then press the second one:
the last button is fired, and the first one released!
Please find here the fla to work with, thanks very much by advance!
multiple_keypress.fla
function panelDown() {
if (Key.getCode() == 97) {
//Keypad 1
fireEvent(btn1)
} else if (Key.getCode() == 98) {
//Keypad 2
fireEvent(btn2)
} else if (Key.getCode() == 99) {
//Keypad 3
fireEvent(btn3)
} else if (Key.getCode() == 100) {
//Keypad 4
fireEvent(btn4)
} else if (Key.getCode() == 101) {
//Keypad 5
fireEvent(btn5)
}
}
//
//
var panelListener:Object = new Object();
panelListener.onKeyDown = panelDown;
Key.addListener(panelListener);
//
function fireEvent(mc) {
mc.gotoAndPlay(2);
}