In the movie below the ball bounces off the left and right edges. We use an if statement to determine when the ball has touches the edge.
The ball has the registration point in the top left corner, so we know that it is touching the left edge if ball.x is 0.
If we make the ball turn around when ball.x==0 it will not really look like it actually touches it. Also if we are counting by -3 we may never hit 0 exactly. We know that the ball is at the right edge if ball.x is greater than the width of the stage minus the width of the ball:

We can turn around by multiplying dx by -1. We want to do that when we touch either the left edge OR the right edge. The symbol for OR is || (The | symbol it above the back-slash. It is usually called "pipe".) The symbol for AND is two ampersands: &&
The code is shown below:
//The ball bounces off the left and right edges.
var dx:Number=4; //initial speed in x direction
this.addEventListener(Event.ENTER_FRAME,moveBall);
function moveBall(e:Event): void {
ball.x=ball.x+dx;
if(ball.x>stage.stageWidth-ball.width || ball.x<0) dx=dx*-1;
} //moveBall
Experiment: Download the movie and add dy and make the ball move in both directions. Multiply dy by -1 when the ball touches either the top edge or the bottom edge.
INDEX, Boolean Properties, Moving Ball: Using if, Greetings: Boolean Operators, Bouncing Ball: Using OR, Clicker Clown: Using Else, Making Tea using switch
Next lesson: OOPs: Object Oriented Programming