Bouncing Ball!

decrement ball1.y

Let's start by opening the ball_wrap.fla we've been working on. We may want to go back in case we ruin it, so click File > Save As and name our new file: ball_bounce

Open the Actions window and let's think about how we can reverse the direction of ball1. Right now, we are resetting the Y position when it is greater than the Stage height. Instead of resetting the Y position, let's reset the variable speed to be a negative number:

The ball should hit the bottom of the Stage, then reverse course (only to disappear off the top):

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

How exactly is that working? Nothing changes with the statement that moves our ball:


What is changing is the value of speed, from a positive to a negative. We can do that. We can add a negative number! The value of ball1.y decrements instead of increments.