here is my character' script
onClipEvent (load) {
var yspeed = 0;
var xspeed = 0;
var grav = 1;
var scale = _xscale;
var w = _width/2;
var h = _height/2;
var grounded = false;
var jump = 15;
}
onClipEvent (enterFrame) {
if (Key.isDown(37)) {
this.gotoAndStop(2);
xspeed -= 1;
_xscale = -scale;
}
if (Key.isDown(39)) {
this.gotoAndStop(2);
xspeed += 1;
_xscale = scale;
}
if (Key.isDown(38)) {
if (grounded) {
yspeed = -jump;
}
}
if (!grounded) {
this.gotoAndStop(3);
}
if (!Key.isDown(37) && !Key.isDown(39) && !Key.isDown(38) && grounded == true) {
this.gotoAndStop(1);
}
yspeed += grav;
_y += yspeed;
_x += xspeed
xspeed *= .93;
grounded = false;
if (_root.ground.hitTest(_x-w, _y, true)) {
xspeed = 0;
while (_root.ground.hitTest(_x-w, _y, true)) {
xspeed = 0;
_x += .1;
}
}
if (_root.ground.hitTest(_x+w, _y, true)) {
while (_root.ground.hitTest(_x+w, _y, true)) {
_x -= .1;
}
}
if (_root.ground.hitTest(_x, _y-h, true)) {
yspeed = 0;
while (_root.ground.hitTest(_x, _y-h, true)) {
_y += .1;
}
}
if (_root.ground.hitTest(_x, _y+h, true)) {
yspeed = 0;
while (_root.ground.hitTest(_x, _y+h, true)) {
_y -= .1;
}
}
if (_root.ground.hitTest(_x, _y+h+20, true)) {
grounded = true;
}
}
It works to be truthful there are no errors but the sound doesn't play