Jumping problem getting closer to solved!

Ok, I finally am coming to a close with my jumping problems!:party: I have only a few problems in the process though. when he jumps, he gos up, right? well, if he lands on a higher platform, he bumps on it, then falls through it :huh:! my code is the following:

 
onClipEvent (load) {
jumping = 0;
gravity = 9.8;
startspeed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE) and jumping == 0) {
this.gotoAndStop("jump");
jumping = 1;
starttime = getTimer()/1000;
startpos = _y;
}
if (jumping == 1) {
time = getTimer()/1000-starttime;
_y = _y-(startspeed-gravity*time);
if (_y>startpos) {
_y = startpos;
jumping = 0;
}
if (_root.walls.hitTest(getBounds(_root).xMax, _y, true)) {
this._x -= 2;
}
if (_root.walls.hitTest(getBounds(_root).xMin, _y, true)) {
this._x += 2;
}
if (_root.walls.hitTest(_x, getBounds(_root).yMin, true)) {
this._y += 5;
}
if (_root.walls.hitTest(_x, getBounds(_root).yMax, true)) {
this._y -= 9.8;
}
}
}

I have NO clue whats wrong, and I am So close to finishing my jumping problem! Please help!

-elPooter.