Ball bouncing off paddle

Hi im was wondering if anyone knows the script for a ball bouncing off a paddle. I want the ball to bounce off the paddle in different directions depending on:

  1. which side of the paddle it hits
  2. which direction it came from

Ive only got this so far : script for the paddle

onClipEvent(enterFrame)
{
if (this.hitTest(_parent.ball)) //if this movieclip hits the movieclip ‘ball’
tellTarget(_root.ball) //tell the ball to:
{
speedX = speedX; //X speed will stay constant
speedY = -speedY; //Y speed will be reversed (direction is reversed)