JavaScript tutorial:
Animation sequencing

 

Use your JavaScript Editor to open MoveImages.htm (in the Tutorial folder inside your JavaScript Editor folder) and examine the code. The script demonstrates how to control the sequence of events, in this case 3 animations one after another.

To run the code click on the Show Internal Viewer button, or
Click here to open MoveImages.htm in the browser.

The code is similar to the previous example, the main difference being a new function: cpSequencer():

function cpSequencer(n)
{
switch(n)
{
case 0:
moveObj(JS1, 61);
break;
case 1:
moveObj(JS2, 121);
break;
case 2:
moveObj(JS3, 181);
break;
case 3:
default:
alert("Animation completed");
break;
}
}

The cpSequencer() function controls the animation through a switch statement, deciding what to do next.

Next