Stoev
11-08-2004, 03:08 PM
Hi everyone.
It is my experince that when you use the Key.isDown method it can only handle 3 keys at once. If you press 4 keys at the same time, one of the keys is just ignored. This is a big problem in a 2-player game.
I also tried to use a listener that changed the value of an array, so that the onEnterFrame event checked the array rather than the Key.isDown.
x = new Array( 6 );
mc.onEnterFrame = function() {
if (x[0] == 1) this.mc_1._alpha = 50;
else this.mc_1._alpha = 100;
if (x[1] == 1) this.mc_2._alpha = 50;
else this.mc_2._alpha = 100;
if (x[2] == 1) this.mc_3._alpha = 50;
else this.mc_3._alpha = 100;
if (x[3] == 1) this.mc_4._alpha = 50;
else this.mc_4._alpha = 100;
if (x[4] == 1) this.mc_5._alpha = 50;
else this.mc_5._alpha = 100;
if (x[5] == 1) this.mc_6._alpha = 50;
else this.mc_6._alpha = 100;
}
mc.onKeyDown = function() {
if (Key.getCode() == 65) x[0] = 1;
if (Key.getCode() == 83) x[1] = 1;
if (Key.getCode() == 68) x[2] = 1;
if (Key.getCode() == 100) x[3] = 1;
if (Key.getCode() == 101) x[4] = 1;
if (Key.getCode() == 102) x[5] = 1;
}
mc.onKeyUp = function() {
if (Key.getCode() == 65) x[0] = 0;
if (Key.getCode() == 83) x[1] = 0;
if (Key.getCode() == 68) x[2] = 0;
if (Key.getCode() == 100) x[3] = 0;
if (Key.getCode() == 101) x[4] = 0;
if (Key.getCode() == 102) x[5] = 0;
}
Key.addListener( mc );
But it made no difference.
Does anyone know if it is even possible to detect more than 3 keys at once?
Stoev
It is my experince that when you use the Key.isDown method it can only handle 3 keys at once. If you press 4 keys at the same time, one of the keys is just ignored. This is a big problem in a 2-player game.
I also tried to use a listener that changed the value of an array, so that the onEnterFrame event checked the array rather than the Key.isDown.
x = new Array( 6 );
mc.onEnterFrame = function() {
if (x[0] == 1) this.mc_1._alpha = 50;
else this.mc_1._alpha = 100;
if (x[1] == 1) this.mc_2._alpha = 50;
else this.mc_2._alpha = 100;
if (x[2] == 1) this.mc_3._alpha = 50;
else this.mc_3._alpha = 100;
if (x[3] == 1) this.mc_4._alpha = 50;
else this.mc_4._alpha = 100;
if (x[4] == 1) this.mc_5._alpha = 50;
else this.mc_5._alpha = 100;
if (x[5] == 1) this.mc_6._alpha = 50;
else this.mc_6._alpha = 100;
}
mc.onKeyDown = function() {
if (Key.getCode() == 65) x[0] = 1;
if (Key.getCode() == 83) x[1] = 1;
if (Key.getCode() == 68) x[2] = 1;
if (Key.getCode() == 100) x[3] = 1;
if (Key.getCode() == 101) x[4] = 1;
if (Key.getCode() == 102) x[5] = 1;
}
mc.onKeyUp = function() {
if (Key.getCode() == 65) x[0] = 0;
if (Key.getCode() == 83) x[1] = 0;
if (Key.getCode() == 68) x[2] = 0;
if (Key.getCode() == 100) x[3] = 0;
if (Key.getCode() == 101) x[4] = 0;
if (Key.getCode() == 102) x[5] = 0;
}
Key.addListener( mc );
But it made no difference.
Does anyone know if it is even possible to detect more than 3 keys at once?
Stoev