Hello,
I can place the following code on a movieclip:
PHP Code:
onClipEvent(load) {
    
gravity 0.2;
    
yspeed 0;
    
speed 2;
}
onClipEvent(enterFrame) {
    if(
flipped) {
        
this._xscale = -this._xscale;
        
flipped false;
    }
    if(
this._x >= 763 or this._x <= 37) {
        
flipped true;
        
speed = -speed;
    }
    if(!
_parent.bricks.hitTest(_x+_width/2_y+_height/4true)) {
        
_x += speed;
    }
    
yspeed += gravity;
    while(
_parent.bricks.hitTest(_x_y+_height/2true)) {
        
_y--;
        
yspeed 0;
        
jumping 0;
    }
    if((!
_parent.bricks.hitTest(_x_y+_height/2+1true)) or (yspeed<0)) {
        
_y += yspeed;
    } else {
        
yspeed 0;
        
jumping 0;
    }

And it'll work fine, however if I place it like this on a frame in the movieclip:
PHP Code:
this.onLoad = function() {
    
gravity 0.2;
    
yspeed 0;
    
speed 2;
}
this.onEnterFrame = function() {
    if(
flipped) {
        
this._xscale = -this._xscale;
        
flipped false;
    }
    if(
this._x >= 763 or this._x <= 37) {
        
flipped true;
        
speed = -speed;
    }
    if(!
_parent.bricks.hitTest(_x+_width/2_y+_height/4true)) {
        
_x += speed;
    }
    
yspeed += gravity;
    while(
_parent.bricks.hitTest(_x_y+_height/2true)) {
        
_y--;
        
yspeed 0;
        
jumping 0;
    }
    if((!
_parent.bricks.hitTest(_x_y+_height/2+1true)) or (yspeed<0)) {
        
_y += yspeed;
    } else {
        
yspeed 0;
        
jumping 0;
    }

It doesn't work

Any help would be greatly appreciated since this is for a school project due in a week...