code in frame 1 layer 1
//stop Demo
//demonstrates stopping at border
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(){
//stop demo - stop as soon as ball encounters edge
//keep ball entirely on stage
//ball leaves right side
if (ball._x > Stage.width - (ball._width/2)){
ball.dx = 0;
ball.dy = 0;
} // end if
//ball leaves left side
if (ball._x < ball._width/2){
ball.dx = 0;
ball.dy = 0;
} // end if
//ball leaves bottom of stage
if (ball._y > Stage.height - (ball._height/2)){
ball.dx = 0;
ball.dy = 0;
} // end if
//ball leaves top of stage
if (ball._y < ball._height/2){
ball.dx = 0;
ball.dy = 0;
} // end if
} // end checkboundaries