Screen Wrap a Moving Object

Stage Height

Finally, we're going to change that boundaryBottom value to equal the Stage height. You can go into the Properties window and lookup the value... mine is 350px:

But what if we want to change the size of our Stage later? We would have to go back and change our ActionScript as well! A better solution, is to have Flash use it's built-in ability to lookup the value of the Stage height property for us.

Just like MovieClips, the Stage is an object with it's own properties. The Stage doesn't have a Y value, but it does have a stageHeight value:

This wrap was a snap:

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

Get Adobe Flash player

Finally, we see an added value of using variables. Had we used stage.stageHeight in our if statement, we would be asking Flash to compute that value over and over again (24 times per second, in fact). That would be an enormous waste. Our way, Flash looks up the value one time, and stores that value in the boundaryBottom variable!