The script animates the image by moving it from its initial location to the specified location.
To run the code click on the Show Internal Viewer button, or
Click here to open MoveImage.htm in the browser.
The key to moving an object is the function moveObjRight(obj):
window.setTimeout("moveObjRight(" +obj.id+ ");", 0);
The function moves an object by 2 pixels and calls the timer function setTimeout(), which calls the moveObjRight() function after a certain period of time has passed. This process is repeated until the animation has been completed.
Note the way setTimeout() is passing a parameter to moveObjRight(): " +obj.id+ "
This means that what is inside the +..+ marks is a variable.