3 Replies Latest reply on Aug 13, 2010 12:06 PM by kglad

    key release

    dn0myar06

      is there an opposite for (Key.isDown(Key.LEFT))

      i tried Key.isUp but its not working...

       

      anyone knows the code for key release???

        • 1. Re: key release
          kglad Adobe Community Professional & MVP

          there's an onKeyUp key listener:

           

           

          var ko:Object={};

          ko.onKeyUp=function(){

          // do whatever

          }

          Key.addListener(ko);

          • 2. Re: key release
            dn0myar06 Level 1

            its quite wotking but when i release the

            right key it does the same with the left...

             

                if (Key.isDown(Key.LEFT)) {
                    _root.caloy_left.gotoAndPlay(21);
                    this._x = this._x-speed;
                    var ko:Object={};
                    ko.onKeyUp=function(){
                    _root.caloy_left.gotoAndPlay(40);
                    }
                    Key.addListener(ko);
                }
                if (Key.isDown(Key.RIGHT)) {
                    _root.caloy_left.gotoAndPlay(1);
                    this._x = this._x+speed;

                    //no release code yet
                }

            • 3. Re: key release
              kglad Adobe Community Professional & MVP

              you have to test for which key is released when the onKeyUp is triggered if you want to take different actionsc for different keys:

               

               

              ko.onKeyUp=function(){

              if(Key.getCode()==37){

              // left

              } else if(Key.getCode()==39){

              // right

              }
              }
              Key.addListener(ko);

               

              p.s.  please mark this thread as answered, if you can.