DHTML : Step 2: Animating the menu
Dr Benton
Starting the Script!
The execution of the script is started by calling up the
choreographer function from the index.htm file. At call time, the function is passed an argument, the '
preload' string. This value is simply a word, just like any other one. Actually, this function plays a big role and handles many
different aspects of our menu. It is made up of several groups of instructions, each group being implemented as a
case of a
switch statement. The processing of the appropriate case depends on the argument received by the function:
200: function choreographer() {
201: var arg = choreographer.arguments;
202:
203: switch(arg[0]) {
204: case 'preLoad' :
[...]
216: break;
217:
218: case 'layerSetup' :
[...]
234: break;
Do not worry now about understanding which bit of the code does what. Just spot the
switch on line 203. It detects the argument passed to the function and executes the corresponding code. Since the argument passed
to the function here is the above-mentioned '
preload' string, the instructions on lines 204 to 216 are executed. The
break keyword on line 216 terminates the execution of the switch, and of the function, too, since there is no other instruction
following the switch.
Don't let these calls to the
choreographer function, such as
choreographer('preLoad') or
choreographer('layerSetup'), worry you. Just search for the
case group of instructions corresponding to the passed argument and see what happens.