Making Mario Like Game, need help!

I have made almost everything perfect in the game, but I am missing some crucial parts.

  1. When I hit the Up key, Mario will jump. The problem is that he will continuously jump until I start to move left or right.
  2. I am trying to make it so that if Mario jumps and hits a goomba while he jumps, the goomba will die. Also, when Mario isn’t jumping, and he hits the goomba, he will die instead. I can’t get either to work, so I was wondering if somebody had some sample code.
  3. I made a hitTest for Mario so when he hits the ground, he will stop falling. Problem is that he falls half way through the ground before he stops.

My code for mario:

onClipEvent (load) {
vel_y = 0;
started = true;
jumping = false;
xspeed = 5;
this.stop();
_quality = “high”;
}
onClipEvent (enterFrame) {
if (started) {
if (move) {
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop(“run”);
this._xscale = -100;
}
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(“run”);
this._xscale = 100;
}
}
}
}
onClipEvent (enterFrame) {
if (started) {
if (Key.isDown(Key.LEFT)) {
this._x -= xspeed;
}
if (Key.isDown(Key.RIGHT)) {
this._x += xspeed;
}
if (Key.isDown(Key.UP) && !jumping) {
this.gotoAndStop(“jump”);
move = false;
vel_y = 9;
jumping = true;
}
if (jumping == true) {
vel_y -= 1;
if (vel_y<=-9) {
vel_y = -9;
}
this._y -= vel_y;
}
if (!_root.groundtest.hitTest(this._x, this._y+15, true) && !jumping) {
fall += 1;
move = false;
this.gotoAndStop(“jump”);
if (fall>9) {
fall = 9;
}
this._y += fall;
}
if (_root.groundtest.hitTest(this._x, this._y+15, true)) {
if (vel_y<=1) {
fall = 0;
vel_y = 0;
jumping = false;
this.jump.gotoAndStop(“run”);
move = true;
}
}
}
}
onClipEvent (keyUp) {
if (move) {
if (Key.getCode() == Key.RIGHT) {
this.gotoAndStop(“idle”);
}
if (Key.getCode() == Key.LEFT) {
this.gotoAndStop(“idle”);
}
if (Key.getCode() == Key.DOWN) {
this.gotoAndStop(“idle”);
xspeed = 5;
}
}
}
I have followed almost every tutorial I’ve seen for jumping and hitTests, but I just can’t seem to get it right. Help would be appreciated.