Movement idea (need help)

I have an idea for movement but I still need help on it.

 
onClipEvent(enterFrame){
  if(_root.pongblock._y>(this._y+this._height/2)){
    //move the paddle down
    _y+=2;
  }else{
    //move the paddle up
    _y-=2;
  }
  //if the paddle moves below the stage area, move it back to the bottom of the stage
  if((this._y+this._height)>Stage.height){
    this._y=Stage.height-this._height;
  }
  //if the paddle moves above the stage area, move it back to the top of the stage
  if(this._y<0){
    this._y=0;
  }
  //Check if the paddle hits the pong block
}
 

It works like the ai for pong but I need to make it follow the ball left and right too.
Heres the code for the ball:

 
onClipEvent(load){
  //Create a variable which determines that the block will move right
  var xspeed=5;
  //Create a variable which determines that the block will move down
  var yspeed=5;
}
//This section is processed every frame
onClipEvent(enterFrame){
  //Check if the pong block has gone below the stage area
  if((this._y+this._height)>Stage.height){
    //set the pong block to the bottom edge of the stage
    this._y=Stage.height-this._height;
    //set the pong block to move up
    yspeed*=(-1);
  }
  //Check if the pong block has gone above the stage area
  if(this._y<0){
    //set the pong block to the top edge of the stage
    this._y=0;
    //set the pong block to move down
    yspeed*=(-1);
  }
 
 
  //Check if the pong block has gone to the left or right of the stage area
  if((this._x+this._width<0) || (this._x>Stage.width)){
    //left side scored
    if(this._x>Stage.width){_root.leftscore++;}
    //right side scored
    if(this._x+this._width<0){_root.rightscore++;}
    //set the pong block to the middle of the stage
    this._x=Stage.width/2;
    //set the pong block to move in the opposite direction horizontally
    xspeed*=(-1);
  } 
  //move the x and y positions of the pong block
  _x+=xspeed;
  _y+=yspeed;
}
 

I just need the ball to stop reseting it’s position and bounce off the walls.

Thanks that all I needed help with ^^