8 Replies Latest reply on Jun 30, 2007 1:32 AM by chinmayagoyal

    sprite movement using arrow keys

    chinmayagoyal
      Hello,
      I have been working on a dragonball z game recently and I have encountered a problem with the sprites.I have traced the bitmap and everything else and even created a movieclip of the sprite.I have put this code on the movieclip-

      Code: ( text )
      onClipEvent (load) {
      step = 5;
      }
      onClipEvent (enterFrame) {
      if (Key.isDown(Key.RIGHT) && this._x<550) {
      this._x += step;
      gotoAndPlay(2);
      } else if (Key.isDown(Key.LEFT) && this._x>0) {
      this._x -= step;
      gotoAndPlay(10);
      } else if (Key.isDown(Key.UP) && this._y>0) {
      this._y -= step;
      gotoAndPlay(15);
      } else if (Key.isDown(Key.DOWN) && this._y<400) {
      this._y += step;
      gotoAndPlay(6);
      }
      }


      I have put animations of the character walking on the differnet frames inside the movieclip.For eg-
      I have shown the character walking right from frame 2-5,walking down from frame 6-9,walking left from frame10-14,walking up from frame 15-19.
      THE PROBLEM is that whenever I press a specefic key(I will take the example of right) and keep it pressed,IT DOES NOT PLAY THE WHOlE ANI:MATION OF MOVING RIGHT.It just plays frame 2 and repeats it instead of playing frames 2-5 together.
      HELP is required!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!