<!-- This example is from the book _JavaScript: The Definitive Guide_. --> <!-- Written by David Flanagan. Copyright (c) 1996 O'Reilly & Associates. --> <!-- This example is provided WITHOUT WARRANTY either expressed or implied.--> <!-- You may study, use, modify, and distribute it for any purpose. --> <!-- The image that will be animated. Give it a name for convenience --> <IMG SRC="images/0.gif" NAME=animation> <SCRIPT> // Create a bunch of off-screen images, and get them started // loading the images we're going to animate. images =index.html new Array(10); for(var i = 0; i < 10; i++) { images[i] =index.html new Image(); // Create an Image object images[i].src = "images/" + i + ".gif"; // tell it what URL to load } // Later, when we want to perform our animation, we can use these URLs, // knowing that they've been loaded into the cache. Note that we perform // the animation by assigning the URL, not the Image object itself. // Also note that we call the image by name, rather than as document.images[0] function animate() { document.animation.src = images[frame].src; frame = (frame + 1)%10; timeout_id = setTimeout("animate()", 250); // display next frame later } var frame = 0; // keep track of what frame of the animation we're on. var timeout_id = null; // allows us to stop the animation. </SCRIPT> <FORM> <!-- Buttons to control the animation --> <INPUT TYPE=button VALUE="Start" onClick="if (timeout_id ==index.html null) animate()"> <INPUT TYPE=button VALUE="Stop" onClick="if (timeout_id) clearTimeout(timeout_id); timeout_id=null;"> </FORM>
file: /Techref/language/java/SCRIPT/definitive/examples/16.1.txt, 1KB, , updated: 1997/4/4 10:59, local time: 2024/11/30 02:29,
18.119.121.234:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/Techref/language/java/SCRIPT/definitive/examples/16.1.txt"> language java SCRIPT definitive examples 16</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.