8 Replies Latest reply on Jan 15, 2007 9:33 AM by mxc

    flash keys

      Hi! i am making a fighting game in Flash 8 and i have a problem...
      i wanted to do
      If( you press X){
      but i only know how to use the code if(Key.isDown(Key.blablabla){
      instead of "blablabla" i only can do another keys that i dont need...

      so how can i do another keys like 'X" or "Z" or whatever... please help me
        • 1. Re: flash keys
          mxc Level 1
          You can find all the key names - key codes - in flash help under

          ActionScript classes > Key

          if thats what you are asking ;)
          • 2. Re: flash keys
            akasama Level 1
            but it does'nt helps me....i can only find there the code i already know...but i need another code for keys.. :(
            • 3. Re: flash keys
              mxc Level 1
              ok I think I understand. Use this code to get the number of ANY key.
              Just paste it into the timeline , test the movie and click away, you can then see all the key codes.

              var keyListener:Object = new Object();
              keyListener.onKeyDown = function() {
              // compare return value of getCode() to constant
              trace("Virtual key code: "+Key.getCode());
              • 4. Re: flash keys
                akasama Level 1
                ummm i dont think u understand...i want to do some codes to my player like that: If( you press the Key "A"){
                If( you press the Key "S"){
                but when i am doing the code : if(Key.isDown(Key. )){
                i can only do keys like SPACE ,ENTER ,UP ,DOWN... and i need another keys...

                umm if u understand me and i dont really understand u forgive me:)

                • 5. Re: flash keys
                  kglad Adobe Community Professional & MVP
                  copy the code mxc gave you in the previous message and paste it into a temporary flash file. go to the flash test environment and press the key you want to use for punch.

                  in the output panel is the key.getCode() that you need. write it down.

                  go back to your game and in the key listener that you currently use put:

                  • 6. Re: flash keys
                    mxc Level 1
                    If you run the code I wrote before and then for example press key A you will see in the output trace that it has a number. All keys have a number and you can use these numbers to write your code.

                    For example if you press X its code is 90 then you know which key == which number

                    The code must be run in flash and then test the movie. I am sure you will see
                    • 7. Re: flash keys
                      akasama Level 1
                      i think i finally got it!!! thx u!!
                      umm wait....where i supposed to put the Virtual key code?
                      like that?
                      if(Key.isDown(Key.getCode()==90 ){
                      // code for punch
                      i sure it will be the last question... :D
                      • 8. Re: flash keys
                        mxc Level 1
                        yes the same code as kglad wrote, put in the number you want, that should be it