Running Problem

Hello.

I have made it so when shift is down my charecter runs however i want this to be in a toggle sort of way.

Starts off as charecter walking
Toggle once then charector starts to jog
Toggle Twice he sprints
Toggled three times then it goes back to the state of walking

This is my code so far where he walks and jogs when shift is pressed:


onClipEvent(load) {
 x_speed2 = 1;
 y_speed2 = 0.5;
}
onClipEvent (enterFrame) {
 if (Key.isDown(Key.SHIFT)){
  x_speed = (x_speed2*3);
  y_speed = (y_speed2*3);
 }
 else {
  x_speed = 1;
  y_speed = 0.5;
 }
}
onClipEvent (enterFrame) {
 if (Key.isDown(Key.RIGHT)) {
  _rotation = 135;
  _x+= x_speed;
  _y+= y_speed;
 }
 if (Key.isDown(Key.LEFT)) {
  _rotation = 315;
  _x-= x_speed;
  _y-= y_speed;
 }
 if (Key.isDown(Key.UP)) {
  _rotation = 45;
  _x+= x_speed;
  _y-= y_speed;
 }
 if (Key.isDown(Key.DOWN)) {
  _rotation = 225;
  _x-= x_speed;
  _y+= y_speed;
 }
 if (Key.isDown(Key.RIGHT) && Key.isDown(Key.UP)) {
  _rotation = 90;
 }
 if (Key.isDown(Key.LEFT) && Key.isDown(Key.UP)) {
  _rotation = 0;
 }
 if (Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)) {
  _rotation = 180;
 }
 if (Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)) {
  _rotation = 270;
 }
}

How do i make it so it toggles through the walk, run, sprint stages?

Thank you :smiley: