Animated Images

Download the most recent version from the scripts page.

Instead of adding a lot of markup to a page, or using animated gif (big files), this script allows use of jpg files for individual animated images. The image is placed in the html normally, and linked to the other images by a script call. It only preloads one image at a time. The advantage is that pages load faster than scripts that preload all images. The disadvantage is that if it's a slow connection, the images may load slower than the animation, so the animation will be forced to slow down.

To set up script:

  1. Insert image
  2. Name image with a unique name for each image that will be animated (I recommend adding both name and id attributes with the same value, for compatibility):
    <img src="gifs/icon01.jpg" alt="fast animation example" name="roll1" id="roll1" height="65" width="65">
  3. Attach the script 'animR2.js' as either a head script, or (preferably) at the end of the page:
    <script type="text/javascript" src="animR2.js"></script>
  4. Add a script at the end of the page before the close </body> tag (must be after the previously attached script) to start the animation for all images. (alternately, you can add a call to the setupAnim() function from an onload = setupAnim(...))
  5. For each animated image, add a call to setupAnim(). Add the time, image name, and list of animation images to setupAnim() for each animated image.
    <script type="text/javascript"><!--
    //  Pass this information for each animation:
    //   setupAnim(seconds between images,name of image,Array(list of images))
    //  (the image written into the page is _not_ included in the list of images)
    
    setupAnim(0.5,'roll1',Array('gifs/icon02.jpg','gifs/icon03.jpg','gifs/icon04.jpg','gifs/icon05.jpg','gifs/icon06.jpg'))
    
    // -->
    </script>

Example Animations

this is the first animation and it's really fast

fast animation example

and this is the second one and it's slower

slow animation example

Copyleft