1. Tech

Your suggestion is on its way!

An email with a link to:


was emailed to:

Thanks for sharing About.com with others!

This is a web page object.

Web Page Animation

9. Moving Vertically

clr gif

Moving vertically is no more difficult than moving horizontally. All we need to do is set a vertical end position and then amend the mover function to update the vertical position instead of the horizontal one. For example:

endPos = (pageHeight()-objHeight('myobj'))/2;

This sets the end position to be the centre of the window vertically.

function mover() {
if (yyy < endPos) {
yyy +=2; moveit(); setTimeout('mover()',50);}

This adds 2 to the Y coordinate to move our object down the screen each time instead of subtracting from the X coordinate to move the object to the left.

All of the other code for the animation would remain unchanged since we are only redefining the end position and direction of movement.

If we wanted to position the objects end position relative to the bottom edge of the screen we would use a fixed distance from posBottom() as our end position.

See More About

©2016 About.com. All rights reserved.