# Running help

**URL:** <https://forum.kirupa.com/t/running-help/327061>\
**Category:** Uncategorized\
**Created:** [February 3, 2012, 8:56am UTC](https://forum.kirupa.com/t/running-help/327061 "2012-02-03T08:56:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Minchken](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@Minchken](https://forum.kirupa.com/u/Minchken)\
**Post date:** [February 3, 2012, 8:56am UTC](https://forum.kirupa.com/t/running-help/327061/1 "2012-02-03T08:56:35Z")

</div>

[COLOR=#D2D8E3][FONT=Arial]Okay so I was watching a tutorial and he gave me this actionscript, I tested it and it worked. but when I press shift I don’t want my character to stay the same I want my character to do a running animation instead of the standard walking, how would I do that?

I am using Flash 8 BTW

Below is my actionscript for my character.[/FONT][/COLOR]  
onClipEvent (load) {  
var speed:Number = 0;  
var walk:Number = 6;  
var run:Number = 11;  
var grav:Number = 0;  
var falling:Number = 0;  
var jumped:Boolean = false;  
var jumpHeight:Number = 21;  
var touchingGround:Boolean = false;  
var scale:Number = \_xscale;  
var doorOpened:Boolean = false;  
var attacked:Boolean = false;  
}  
onClipEvent (enterFrame) {  
if (!touchingGround) {  
grav++;  
this.\_y += grav;  
} else {  
grav = 0;  
}  
if (\_root.ground.hitTest(\_x, \_y, true)) {  
touchingGround = true;  
} else {  
touchingGround = false;  
}  
if (!attacked) {  
if (Key.isDown(Key.LEFT)) {  
\_x -= speed;  
this.gotoAndStop(2);  
\_xscale = -scale;  
}  
if (Key.isDown(Key.RIGHT)) {  
\_x += speed;  
this.gotoAndStop(2);  
\_xscale = +scale;  
}  
if (Key.isDown(Key.SHIFT)) {  
speed = run;  
} else {  
speed = walk;  
}  
}  
}  
onClipEvent (enterFrame) {  
if (!attacked) {  
if (jumped) {  
falling += 0.5;  
\_y += falling;  
if (touchingGround) {  
jumped = false;  
}  
} else {  
if (Key.isDown(Key.UP)) {  
jumped = true;  
falling = -jumpHeight;  
this.gotoAndStop(4);  
}  
}  
}  
if ((Key.isDown(Key.UP)) and (Key.isDown(Key.LEFT))) {  
this.gotoAndStop(4);  
}  
if ((Key.isDown(Key.UP)) and (Key.isDown(Key.RIGHT))) {  
this.gotoAndStop(4);  
}  
if ((!Key.isDown(Key.UP)) and (!touchingGround)) {  
this.gotoAndStop(4);  
} else if ((Key.isDown(Key.UP)) and (!touchingGround)) {  
this.gotoAndStop(4);  
}  
if ((\_currentframe == 4) and (touchingGround)) {  
gotoAndStop(1);  
}  
}  
onClipEvent (keyUp) {  
if (!attacked) {  
gotoAndStop(1);  
}  
}  
onClipEvent (enterFrame) {  
if ((this.hitTest(\_root.door)) and (!doorOpened)) {  
this.\_x -= speed;  
}  
if ((this.hitTest(\_root.door)) and (Key.isDown(Key.SPACE)) and (\_root.keys\>=1)) {  
\_root.door.gotoAndStop(2);  
doorOpened = true;  
\_root.keys -= 1;  
}  
if (this.hitTest(\_root.wall)) {  
this.\_x -= speed;  
}  
if (this.hitTest(\_root.key)) {  
\_root.keys += 1;  
unloadMovie(\_root.key);  
}  
if (\_root.keys\<0) {  
\_root.keys = 0;  
}  
}  
onClipEvent (enterFrame) {  
if (Key.isDown(65)){  
attacked = true;  
this.gotoAndStop(4);  
if(this.hitTest(\_root.enemy)) {  
\_root.enemy.unloadMovie();  
}  
}  
}
