ENTER_FRAME Event Listener

Create a Variable

Well that was easy! Let's make it even easier, in the future, to adjust the speed our ball falls. We don't want to have to hunt for that statement every time we want to make a change (especially after we add more and more lines of code).

Let's abstract that hard number out to a variable! Right at the top of our Actions we can put a variable called speed. Then, we use that variable in our ball1.y statement:

Watch the master:

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

Get Adobe Flash player


Well, that's great! Now, all we have to do to is change the value of the variable speed, which is conveniently found right at the top. Your Actions window should look like this now:


Test it... if you made any spelling mistakes, it won't run anymore:

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

Get Adobe Flash player