|Lesson 9: Images|
Example Image Swap:
A) Pre-Define the images array-
var images=new Array();
This allows us to manipulate the images array before it would normally be created by the normal loading of the HTML document.
B) Define each slot of the array used as an image with the Image() constructor-
This defines the object contained by the images array at the nth position as an Image object with all the properties available.
C) Set the src property of each image
This presets the nth image on the page to a certain graphical file, and begins the download of all data from the file.
The following are some other properties you can access from a loaded image with the WebTv browser:
Note-all above properties are set as HTML attributes except "complete" which is a boolean status indicator (true if the image is loaded).
2) Event Handlers
There are three event handlers for an image object:
A) onAbort fires when the user stops the loading process (computers only, no webtv)
B) onError fires if the image cannot be loaded due to a bad file addy or transfer errors (traffic)
C) onLoad fires once all of the image's data is loaded (including all frames for animations)
Note-the onAbort will not work for WebTv! Try the above script using both good and bad image URLs.