« Rotozoomer with Act... byebye: the solutio... »

Flash player 8 onKeyUp bug

Sep 19th, 2006

What a silly bug made me lose quite a bit of time!!!

Ok, If you were planing of doing a game controled by the keyboard for Flash player 8 you'll find a little BIG issue. Using this code:

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
    trace("PRESSED -> Code: "+Key.getCode()+" ASCII: "+Key.getAscii()+" Key: "+chr(Key.getAscii()));
};
keyListener.onKeyUp = function() {
    trace("RELEASED -> Code: "+Key.getCode()+" ASCII: "+Key.getAscii()+" Key: "+chr(Key.getAscii()));
};
Key.addListener(keyListener);

Then, if you doing this sequence:
1. Press DOWN  (40)
2. Press RIGHT
(39)
3. Release RIGHT (30)
4. Release DOWN (40)

You'll get this result exporting to with Flash
player 7:
PRESSED -> Code: 40    ASCII: 0    Key:
PRESSED -> Code: 39    ASCII: 0    Key:
RELEASED -> Code: 39    ASCII: 0    Key:
RELEASED -> Code: 40    ASCII: 0    Key:


However, with Flash player 8 player you'll get this:
PRESSED -> Code: 40    ASCII: 0    Key:
PRESSED -> Code: 39    ASCII: 0    Key:
RELEASED -> Code: 39    ASCII: 0    Key:


As you can see, Flash player 8 forgets which Keys you pressed as soon as you press another one, but without releasing the previous ones. Which may cause that your ship goes down automaticly.

Well, atleast looks like they've fixed this issue already in Flash player 9.

#permalink

Share:
Digg! ~ del.icio.us ~ Stumble ~ Furl ~ Reddit
Amazing, how can they release new versions without testing this *basic* functionality? :D
Luckily they fixed in flash 9, but now everybody with flash8 can't play that mysterious game you're developing in the dark! Does it have ships and aliens? Then I'd love to test it!
Sep 20th, 2006
sole
Teniendo en cuenta la penetración (perdón x la palabra) del player 9 ultimamente... lo mismo en pocas semanas-meses esto ya no es un problema... o al menos, un problema menor...
Sep 20th, 2006
humphr3y
Well, I guess they fixed that too with flash player 8.5, but I can't be asked testing it now.
Sep 20th, 2006
mr.doob
LARGA VIDA AL TEST!!
Mejor no lo reportes a su bigtracker o te denuncio por intrusismo laboral :D
Sep 20th, 2006
xphere
Hey Ricardo,

I've got the same problem. I'm creating a loop based sequencer in flash wich containes a synthesizer emulator. you can play the synth with the computerkeyboard. Only when you make a chord with more keys, when released it keeps playing the sound of the first button pressed.
Since not everyone has flash player 9 i hope there is another solution... Do you know if there is a way to script around this bug?

Cheers,

erjee
Sep 25th, 2006
erjee
well, I'm sure it must be a way, but I think I won't bother, I'll move directly to 8.5 - 9
Sep 25th, 2006
mr.doob
ow sorry hehe, the name was Mr doob right?
Sep 25th, 2006
erjee
Yep :)
Sep 25th, 2006
mr.doob
Webs / Print / Logos... everything I do will be listed here.



If you're looking for my Actionscript experiments, here you have: