this is the link to the game.. play around and you will see some of the problems i have... like when you hit down (you crouch like i want you to) but then while crouched you hit over left or right he slides left and right and doesnt go to the proper frame.. and when you hit shift to run.. you speed up but dont go to the proper frame... and when you release shift you still have the run speed not walk speed.. and here is my script so you know where i screwed up.. but please explain to me my mistake instead of just correcting it.
onClipEvent (load) {
var grav:Number = 0;
var walk:Number = 5;
var run:Number = 8;
var jumpHeight:Number = 10;
var slow:Number = .7;
var slowspd:Number = speed/1.5;
var speed:Number = walk;
var scale:Number = _xscale;
var ex:Number = 7;
this.gotoAndStop(2);
}
onClipEvent (enterFrame) {
grav++;
_y += grav;
while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
}
if (_root.water.hitTest(_x, _y, true)) {
if (grav>0) {
grav *= slow;
}
speed = slowspd;
} else {
speed = walk;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
_xscale = scale;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(5);
}
} else if (Key.isDown(Key.LEFT)) {
_x -= speed;
_xscale = -scale;
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(5);
}
}else{
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(3);
}
}
if (Key.isDown(Key.SHIFT)) {
walk = run;
}else{
walk = speed;
}
if (Key.isDown(Key.SHIFT) && !Key.isDown(Key.LEFT)) {
this.gotoAndStop (6);
}
if (Key.isDown(Key.SHIFT) && !Key.isDown(Key.RIGHT)) {
this.gotoAndStop (6);
}
if (Key.isDown(Key.DOWN)) {
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(8);
}else{
this.gotoAndStop (5)
}}
if (Key.isDown(Key.UP) && _root.ground.hitTest(_x, _y+3, true)) {
grav = -jumpHeight;
_y -= 4;
this.gotoAndStop(2);
}
if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height-15, true)) {
grav = 1;
}
}