code in frame 1 layer 1

//Bounce Demo
//demonstrates bouncing off walls

ball.dx = 5;
ball.dy = 5;

ball.onEnterFrame = function(){
  ball.move();
  ball.checkBoundaries();
} // end enterFrame

ball.move = function(){
  ball._x += ball.dx;
  ball._y += ball.dy;
} // end move

ball.checkBoundaries = function(){
  //bounce demo - bounce off walls
  //keep ball entirely on stage

  //ball leaves right side
  if (ball._x > Stage.width - (ball._width/2)){
    ball.dx = -ball.dx;
  } // end if

  //ball leaves left side
  if (ball._x < ball._width/2){
    ball.dx = -ball.dx;
  } // end if

  //ball leaves bottom of stage
  if (ball._y > Stage.height - (ball._height/2)){
    ball.dy = -ball.dy;
  } // end if

  //ball leaves top of stage
  if (ball._y < ball._height/2){
    ball.dy = -ball.dy;
  } // end if

} // end checkboundaries