Flash 8 - Key class bug or feature?

Friday, October 7th, 2005

I 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]

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.

AddThis Feed Button

This is some text prior to the author information. You can change this text from the admin section of WP-Gravatar  I'm living in Bratislava, Slovakia. I'm Senior Flex, AIR Developer for my own company Flexets. Read more from this author


tagged under:

ABOUT THIS AUTHOR

I'm living in Bratislava, Slovakia. I'm Senior Flex, AIR Developer for my own company Flexets.

Get a Trackback link

15 Comments


  1. 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).


  2. mike lyda
    Visit Site
    October 7th, 2005

  3. 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.


  4. 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…


  5. Administrator
    Visit Site
    October 7th, 2005

    Ups, __mylistener is just typo, i will fix it.


  6. 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.


  7. 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.


  8. Karel
    Visit Site
    October 7th, 2005

  9. Administrator
    Visit Site
    October 7th, 2005

    I’ve already added it to livedocs on Key.onKeyUp event


  10. 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?


  11. 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.


  12. 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


  13. 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


  14. Matt
    Visit Site
    February 7th, 2006

    Definitely a very frustrating bug for flash games


  15. 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

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

This site is using OpenAvatar based on
Images is enhanced with WordPress Lightbox JS by Zeo
Clicky Web Analytics