please dont rip this site

Language Java Script Definitive Examples 16.2.TXT

 <!-- 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>
var frame =index.html 0;         // keep track of what frame of the animation we're on.
var timeout_id = null; // allows us to stop the animation.

function animate()  // The function that does the animation.
{
    document.animation.src = images[frame].src;
    frame = (frame + 1)%10;
    timeout_id = setTimeout("animate()", 250);  // display next frame later
}

// Count how many images have been loaded.  When we reach 10, start animating
function count_images() {  if (++num_loaded_images == 10) animate(); }
var num_loaded_images = 0;

// Create the off-screen images and assign the image URLs.
// Also assign an event handler so we can count how many images have been
// loaded.  Note that we assign the handler before the URL, because otherwise
// the image might finish loading (if it is already cached, e.g.) before
// we assign the handler, and then we'll lose count of how many have loaded!
images = new Array(10);
for(var i = 0; i < 10; i++) {
    images[i] =index.html new Image();                 // Create an Image object
    images[i].onload = count_images;         // assign the event handler
    images[i].src = "images/" + i + ".gif";  // tell it what URL to load
}
</SCRIPT>

<!-- Buttons to control the animation.  Note that we don't let the user
  -- start the animation before all the images are loaded -->
<FORM>                   
  <INPUT TYPE=button VALUE="Start" 
         onClick="if (!timeout_id && num_loaded_images==10) 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.2.txt, 2KB, , updated: 1997/4/4 10:59, local time: 2024/11/27 06:27,
TOP NEW HELP FIND: 
3.15.225.177: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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/Techref/language/JAVA/script/definitive/examples/16.2.txt"> language JAVA script definitive examples 16</A>

Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .