133Chapter 12Images and Dynamic (Space web hosting) HTMLListing 12-1:Precaching Images Image
Saturday, August 18th, 2007133Chapter 12Images and Dynamic HTMLListing 12-1:Precaching Images
Image Object

As the page loads, it executes several statements immediately. These statements create anempty array that is populated with four new memory image objects. Each image object has afilename assigned to its srcproperty. These images are loaded into the image cache as thepage loads. Down in the Body portion of the document, an tag stakes its turf on thepage and loads one of the images as a starting image. A selectelement lists user-friendly names for the pictures while housing the names of imageobjects already precached in memory. When the user makes a selection from the list, theloadCached()function extracts the selected item s value which is a string index of theimage within the imageLibraryarray. The srcproperty of the chosen image object isassigned to the srcproperty of the visible image object on the page, and the precachedimage appears instantaneously.