Moving 2

Well, this DHTML method is not just last chapter's moving. It is animation. Yes, animation is the best description of this method. This method uses looping for scrolling or animating objects. Here is the simple code:

  moving.xpos += 5  moving.left = moving.xpos  

This code means move moving 5 pixels to left. Then you need to put looping script to HTML.

  function animation() {	if (moving.xpos < 350) {		moving.xpos += 5		moving.left = moving.xpos		setTimeout("animation()",20)	}  }  

If statment determined where object need to stop. You can remember moving.left = moving.xpos. setTimeout() statment is what creates the loop. This animation will repeat every 20 milliseconds.

Here is the example

Back to home