A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: key listeners problem... plese help

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    8

    key listeners problem... plese help

    hi all,

    my problem has changed... scroll down...
    Last edited by freddiy; 02-26-2006 at 09:08 PM.

  2. #2
    Junior Member
    Join Date
    Feb 2006
    Posts
    8
    noone?

  3. #3
    Junior Member
    Join Date
    Feb 2006
    Posts
    8
    ok, I dug around the forum and found out that it is a bug in flash 8... something macromedia should fix asap me think... or is it fixed? im using 8.0...

  4. #4
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    Can you post the .fla?

    I'll try and fix it for you.

  5. #5
    Junior Member
    Join Date
    Feb 2006
    Posts
    8
    Can you post the .fla?

    I'll try and fix it for you.
    nah, not my big blob pinball game

    but here is a .fla from another thread regardning the same situation. publish this one as MX2004/flash7 first, then, switch to flash 8 and try holding several keys... and... bug! flash fails to catch onKeyUp's... if you can make it this one work as flash 8 my, and it seems, many others problem is solved... (my game uses bitmapdata everywhere and scrollrect so MX 2004/flash7 isn't an option here...)
    Attached Files Attached Files
    Last edited by freddiy; 02-26-2006 at 08:45 PM.

  6. #6
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    Quote Originally Posted by freddiy
    So onKeyUp seems to be notified only for the last key that notified onKeyDown... anyone recognize and have some solution to this problem? (I'm using flash 8.)
    Well, not exactly true. onKeyUp is notified but the problem is that Key.getCode() returns the code of the last pressed button.

    I guess a work around would be to check on each frame if shift or control are pressed with Key.isDown() method and if not the flipper is up and if yes flipper is down.
    Last edited by Smilev; 02-26-2006 at 08:41 PM.
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  7. #7
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    Quote Originally Posted by freddiy
    ok, I dug around the forum and found out that it is a bug in flash 8... something macromedia should fix asap me think... or is it fixed? im using 8.0...
    It's not really a bug but it's how the getCode method works.
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  8. #8
    Junior Member
    Join Date
    Feb 2006
    Posts
    8
    Quote Originally Posted by Smilev
    Well, not exactly true. onKeyUp is notified but the problem is that Key.getCode() returns the code of the last pressed button.

    I guess a work around would be to check on each each frame if shift or control are pressed with Key.isDown() method and if not the flipper is up and if yes flipper is down.
    ok, well i tried a Key.isDown() modification but problem remains... check the .fla i posted above! it uses isDOwn.
    Last edited by freddiy; 02-26-2006 at 08:44 PM.

  9. #9
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    Well, I wanted to look at your .fla because I don't think you implemented it properly.

    It should be

    keyListenerName.onKeyUp = function() {

    }

    keyListerName being the name you gave your keyListener

    not

    keyListener.onKeyUp = function() {

    }

  10. #10
    Junior Member
    Join Date
    Feb 2006
    Posts
    8
    Quote Originally Posted by AfternoonDelite
    Well, I wanted to look at your .fla because I don't think you implemented it properly.

    It should be

    keyListenerName.onKeyUp = function() {

    }

    keyListerName being the name you gave your keyListener

    not

    keyListener.onKeyUp = function() {

    }
    yeah, keyListener is the name of the object,
    PHP Code:
    var keyListener:Object = new Object();
    //.
    //.
    //onkey function definitions and stuff
    //.
    //.
    Key.addListener(keyListener); 
    anyway, the problem is stated earlier, compare the above key-jam.fla between flash7 & flash8 exports and it should be clear... can't see another explenation than it is a bug causing it.
    Last edited by freddiy; 02-26-2006 at 09:05 PM.

  11. #11
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    Key.isDown works perfectly. Here is a small example I made for you.
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  12. #12
    Senior Member
    Join Date
    May 2002
    Posts
    1,017
    Disregard my last post. You are right, when using Listeners it works when published as Flash7 but not as Flash8. I didn't read carefully your post. BUt you didnt read carefully my either. I said a work around is to check each frame if a key isDown not to use it with listener.

    Here is the correct example. The code is on the two movieclips.
    while (2+2 == 4) {
    drink ("bourbon");
    }
    gotoAndStop("bed");

  13. #13
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    Quote Originally Posted by freddiy
    yeah, keyListener is the name of the object,
    PHP Code:
    var keyListener:Object = new Object();
    //.
    //.
    //onkey function definitions and stuff
    //.
    //.
    Key.addListener(keyListener); 
    anyway, the problem is stated earlier, compare the above key-jam.fla between flash7 & flash8 exports and it should be clear... can't see another explenation than it is a bug causing it.
    Worked fine for me.

  14. #14
    Junior Member
    Join Date
    Feb 2006
    Posts
    8
    Quote Originally Posted by Smilev
    Disregard my last post. You are right, when using Listeners it works when published as Flash7 but not as Flash8. I didn't read carefully your post. BUt you didnt read carefully my either. I said a work around is to check each frame if a key isDown not to use it with listener.

    Here is the correct example. The code is on the two movieclips.
    lots and lots of big thx! your the best!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center