The movie you're about to see is the finished product. You can create this by making a Movie Clip ball and separate Movie Clips for walls and ground (with respective instance names). Put this script on the ball, and read the // for explanations.
onClipEvent(load){//Apply the following script once (hence 'load')
_root.grav=0;//Recognize the instance 'grav' as a rational number
_root.xmove=0;//Recognize the instance 'xmove' as a rational number
}//Terminate the handler
onClipEvent(enterFrame){/
/Apply this script constantly
this._y+=_root.grav;//Mak e the ball fall at 'grav'
_root.grav+=1;//Make 'grav' increment by 1; you can change the number
this._x+=_root.xmove;//Ma ke the ball move forward at 'xmove'
if(_root.ground.hitTest(_
x,_y,true)){//If this hits the ground do the following
_root.grav*=-1;//Multiply 'grav' by -1, which will make the ball bounce
}//Terminate the if statement
//OPTIONAL SCRIPT!! The following script is optional. Add a Movie Clip with the instance name 'restart' if you want it to do something.
if(_root.restart.hitTest(
_x,_y,true)){//If this hits the restart barrier
this._x=265;//Set the ball's X to 265
this._y=190;//Set the ball's Y to 190
_root.grav=0;//Sets 'grav' to 0
_root.xmove=0;//Sets 'xmove' to 0
}//Terminate the if statement
//WARNING! The optional script stops here! Everything below is essential!
if(_root.walls.hitTest(_x ,_y,true)){//If the ball hits the walls
_root.xmove*=-1;//Multipl y 'xmove' by -1 which will make the ball bounce sideways
}//Terminate the if statement
if(Key.isDown(Key.LEFT)){
//If the left key is pressed
_root.xmove-=1;//Decrease 'xmove' by 1, which will eventually result in 'negative-positive' movement, making the ball move left
}//Terminate the if statement
if(Key.isDown(Key.RIGHT))
{//If the right key is pressed
_root.xmove+=1;//Incremen t 'xmove' by 1, which will result in an eventual rightwards movement
}//Terminate the if statement
if(!Key.isDown(Key.RIGHT)
&&!Key.isDown(Key.LEFT)&&
_root.xmove>0){//If right nor left are pressed and 'xmove' is a positive number do the following
_root.xmove-=1;//Decrease xmove by 1, which will bring the ball to a horizontal standstill
}//Terminate the if statement
if(!Key.isDown(Key.RIGHT)
&&!Key.isDown(Key.LEFT)&&
_root.xmove<0){//If right nor left are pressed and 'xmove' is negative
_root.xmove+=1;//Increase xmove by 1, which will bring the ball to a horizontal standstill
}//Terminate the if statement
if(_root.xmove>15){//If 'xmove' is greater than 15
_root.xmove=15;//Set the speed back to 15, which caps the speed
}//Terminate the if statement
if(_root.xmove<-15){//If 'xmove' is less than -15
_root.xmove=-15;//Set the speed up to -15, which caps the speed
}//Terminate the if statement
}//Terminate the handler