Os cuento lo k quiero...
Intento capturar una secuencia de teclas, normalmente se puede capturar los números del 1 al 9 pq son teclas independientes, pero ¿qué pasa si queremos capturar el 11?
Con este código, si eres rápido tecleando, puedes hacerlo, pues si mantienes pulsada la tecla DOWN, te permite guardar en un array dos valores (Sólo 2).
El problema: Tener pulsada la tecla DOWN también envía valores al Array() por lo que si la mantienes pulsada y tardas en introducir los otros dos, el Array se rellena y devuelve el valor 0.
¿Cómo hacer que los valores arrojados por DOWN no afecten al array?
He probado mil maneras:
Desde decirle a la orden de push.array k sólo acepte valores ascii comprendidos entre 48 y 57 hasta decirle que no acepte ni cero ni undefined, pero no me obedece...
AYUDADME PLEASE
Código :
_global.knumbers = new Array();
_global.knumber = 0;
_global.thenum = 0;
_global.thenum1 = 0;
_global.thenum2 = 0;
var listKey1:Object = new Object();
listKey1.onKeyDown = function () {
if (Key.isDown(Key.DOWN)) {
var listKey:Object = new Object();
listKey.onKeyDown = function () {
_global.knumbers.push(Key.getAscii());
if (_global.knumbers.length == 2){
if (_global.knumbers[0] == 48){
_global.thenum = 0;
}
if (_global.knumbers[0] == 49){
_global.thenum = 1;
}
if (_global.knumbers[0] == 50){
_global.thenum = 2;
}
if (_global.knumbers[0] == 51){
_global.thenum = 3;
}
if (_global.knumbers[0] == 52){
_global.thenum = 4;
}
if (_global.knumbers[0] == 53){
_global.thenum = 5;
}
if (_global.knumbers[0] == 54){
_global.thenum = 6;
}
if (_global.knumbers[0] == 55){
_global.thenum = 7;
}
if (_global.knumbers[0] == 56){
_global.thenum = 8;
}
if (_global.knumbers[0] == 57){
_global.thenum = 9;
}
if (_global.knumbers[1] == 48){
_global.thenum1 = 0;
}
if (_global.knumbers[1] == 49){
_global.thenum1 = 1;
}
if (_global.knumbers[1] == 50){
_global.thenum1 = 2;
}
if (_global.knumbers[1] == 51){
_global.thenum1 = 3;
}
if (_global.knumbers[1] == 52){
_global.thenum1 = 4;
}
if (_global.knumbers[1] == 53){
_global.thenum1 = 5;
}
if (_global.knumbers[1] == 54){
_global.thenum1 = 6;
}
if (_global.knumbers[1] == 55){
_global.thenum1 = 7;
}
if (_global.knumbers[1] == 56){
_global.thenum1 = 8;
}
if (_global.knumbers[1] == 57){
_global.thenum1 = 9;
}
_global.thenum2 = ((_global.thenum)*10)+_global.thenum1;
_root.writeit.text = thenum2;
}
}
Key.addListener(listKey);
}
}
Key.addListener(listKey1); 