2.4 | Looping Animations |
Looping an animation is a piece of cake. After your layer is done it's animation, you just relocate the layer's left position or using the moveBy() method, and then restart the animation. But note that when you do this there's no simple way to stop the animation. A technique will be shown in Part 3 that will address this problem.
function loop() {
if (document.layers["layer1"].left < 300) {
document.layers["layer1"].left += 5;
setTimeout("loop()",30);
}
else {
document.layers["layer1"].left = 50;
setTimeout("loop()",500);
}
}
1.1 Introduction
1.2 Overlapping 1.3 Nesting 1.4 Using JavaScript |
2.1 Sliding Layers
2.2 Pre-Built Functions 2.3 Clipping Layers 2.4 Looping Animations 2.5 Changing Images |
3.1 Mouse-Click Animation
3.2 Capturing Keystrokes 3.3 Drag and Drop 4.1 Making Demos 4.4 Problems 4.5 Screen Sizes |
|