Flash 8 - Key class bug or feature?
Friday, October 7th, 2005I found out one weird problem in Flash 8 with Key class. Let’s see it on example:
Make new FLA in Flash 8, and copy this text on 1st frame:
[as]var myListener = new Object();
myListener.onKeyDown = function()
{
trace(”down: ” + Key.getCode());
};
myListener.onKeyUp = function()
{
trace(”up: ” + Key.getCode());
};
Key.addListener(myListener);[/as]
myListener.onKeyDown = function()
{
trace(”down: ” + Key.getCode());
};
myListener.onKeyUp = function()
{
trace(”up: ” + Key.getCode());
};
Key.addListener(myListener);[/as]
And try this:
- Press any key and hold it
- Press another key and hold it
- Release first key - it should fire onKeyUp with first key - but it doesn’t
If you publish this movie to Flash 7, it works. In Flash 8 it doesn’t work.
So my question is: Is it bug, or feature?
If this is feature, please let me know, how I can fire onKeyUp of first pressed key while second one is still pressed.
Thanks.
tagged under:





15 Comments
Tek
• Visit Site
October 7th, 2005
It is a bug and an annoying one.
The second key released will never emits onKeyUp event under ActiveX (WIN 8,0,22,0) and Firefox (WIN 8,0,22,0) or local player (WIN 8,0,22,0).
mike lyda
• Visit Site
October 7th, 2005
more fun here: http://oddhammer.com/blog/comments.php?id=135_0_1_0_C
(see the test case http://oddhammer.com/tutorials/german.html )
Karel
• Visit Site
October 7th, 2005
Hi, I am not quite convinced that’s a bug. It looks like there’s no queue for keyevents. It just remembers the last input.
Why do you use underscores in front of the myListener-object? It even doesn’t work with underscores in my case.
Administrator
• Visit Site
October 7th, 2005
just because it was was copy and paste from my KeyBuffer class, and it was private variables
but in Flash 7 it works, do you think, that this feature queue for keyevents macromedia removes? I think it’s important feature…
Administrator
• Visit Site
October 7th, 2005
Ups, __mylistener is just typo, i will fix it.
Karel
• Visit Site
October 7th, 2005
Hmm, it’s strange though that it works for Flash 7 (mx 2004).
I couldn’t think of something else then a queue-issue.
Andres
• Visit Site
October 7th, 2005
Yeah, I found about that “problem” while working on a Flash game. The only other way I could achieve what I wanted, which was to detect a keyUp on any key that was released, was to use a combination of onKeyDown and a variable for each key to hold the state of the key (pressed or unpressed) and it worked nicely.
Karel
• Visit Site
October 7th, 2005
You might add this issue to the livedocs: http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002295.html
Administrator
• Visit Site
October 7th, 2005
I’ve already added it to livedocs on Key.onKeyUp event
Administrator
• Visit Site
October 7th, 2005
2. mike lyda | October 7th, 2005 at 1:00 pm
more fun here: http://oddhammer.com/blog/comments.php?id=135010C
Sorry, do not know find that comment, what is exact link?
Patrick Pietens
• Visit Site
October 7th, 2005
Yeah,
I came across the same bug while working on a Flash game. It is definitely a bug which I mailed to Macromedia a month ago. I hope they will fix it really soon.
mike lyda
• Visit Site
October 7th, 2005
weird.. the “135010C” should be “151_0_1_0_C” (151 underscore and then an underscore between all the rest of the characters) it looks like the _ characters were stripped out?
try again. .
http://oddhammer.com/blog/comments.php?id=151_0_1_0_C
Administrator
• Visit Site
October 7th, 2005
do not know, what problems..but in example i have 2 underscores in myLIstener variable, and somewhere _ where removed, somewhere not
do not know, what is it…
Btw, i saw your comment page now
Matt
• Visit Site
February 7th, 2006
Definitely a very frustrating bug for flash games
Ruben
• Visit Site
August 9th, 2006
I started thread on actionscript.org regarding this issue, I thought it might worth subscribing to for some of you (those of you who are members on the forums, that is)..
http://www.actionscript.org/forums/showthread.php3?t=113669
Cheers..
PS. Franto, I hope you don’t mind me posting this here, if you do feel free to delete my comment.
Live Preview
Leave a comment