1 Reply Latest reply on Mar 21, 2012 1:09 PM by prodigalmaster

    how to make a movieclip play only while a key is pressed?

    maxus phinus

      this is the code i am using, i get what flash is doing, after i release the key it starts to play the "walking" frames- only i include the gotoAndStop("idle") so it doesn't get to play "walking".

      but what i am looking for it to do is play the  walking only when the key is pressed and stop when released.

       

      onClipEvent (enterFrame) {

                if (Key.isDown(Key.RIGHT))//68

                {

                          this._x += moveSpeed;

                          this.legs.gotoAndPlay("walking");

                          this._xscale = 100;

                }

                else if (Key.isDown(Key.LEFT))//65

                {

                          this._x -= moveSpeed;

                          this.legs.gotoAndPlay("walking");

                          this._xscale = -100;

                }

                else

                {

                          this.legs.gotoAndStop("idle");

                }

      }