The problem when it crashed was that you werent actually getting him out of the ground you were just setting yspd to 0 and because the character was still touching the platform it continued to loop through the code and he never got moved out with the code inside, an infinite loop.
Essentially you should be able to do the following:
onClipEvent(load){
xspd = 0;
yspd = 0;
}
onClipEvent(enterFrame){
_x += xspd;
_y += yspd;
yspd += 1;
if (this.hitTest(_root.p1) || this.hitTest(_root.p2)){
yspd = 0;
}
while (this.hitTest(_root.p1) || this.hitTest(_root.p2)) {
_y--
}
}
This is should work but is likely to make the character sort of bounce on the surface of the ground if you catch my meaning.
However if that doesn't work well maybe you can try figuring the y position required to be above the ground then not use the while statement but in the if statement and a line that sets the _y value to the location on the surface of the ground.