[Javascript] Image Preloader

Henrik Danielsson h.danielsson at gmail.com
Mon Jun 19 11:04:58 CDT 2006


Hello,

That code is incomplete, and has a typo: call-back should be call_back (-
isn't allowed in a variable name).
I've seen the the page from which this script comes. Sorry, but I don't
remember the address.
You need the ImagePreloader.prototype.XXXXX functions too,
I suggest you look at the source of the example page provided on that site
if you have the address.
It has the complete working code in it.

\Henrik
2006/6/19, suresh kumar <asureshkumar_1983 at yahoo.co.in>:
>
>  function ImagePreloader(images, call-back)
> {
>    // store the call-back
>    this.call-back = call-back;
>
>    // initialize internal state.
>    this.nLoaded = 0;
>    this.nProcessed = 0;
>    this.aImages = new Array;
>
>    // record the number of images.
>    this.nImages = images.length;
>
>    // for each image, call preload()
>    for ( var i = 0; i < images.length; i++ )
>       this.preload(images[i]);
> }
> The call-back function is stored for later use, then each image URL is
> passed into the preload() method.
>
> ImagePreloader.prototype.preload = function(image)
> {
>    // create new Image object and add to array
>    var oImage = new Image;
>    this.aImages.push(oImage);
>
>    // set up event handlers for the Image object
>    oImage.onload = ImagePreloader.prototype.onload;
>    oImage.onerror = ImagePreloader.prototype.onerror;
>    oImage.onabort = ImagePreloader.prototype.onabort;
>
>    // assign pointer back to this.
>    oImage.oImagePreloader = this;
>    oImage.bLoaded = false;
>
>    // assign the .src property of the Image object
>    oImage.src = image;
> }
>
>
> This code i downloaded from net for loading images in my project.I am
> displaying images in infinite loop untill i close the browser.But i want
> Particular images is to run for some specific no of times.How can i
> achieve this task.If any one having the code send me
>
>
> A.suresh
>
> ------------------------------
> Yahoo! India Answers: Share what you know. Learn something new Click here<http://us.rd.yahoo.com/mail/in/mailanswersshare/*http://in.answers.yahoo.com/>
> Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download
> now<http://us.rd.yahoo.com/mail/in/freesms/*http://messenger.yahoo.com/download.php>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript<https://lists.latech.edu/mailman/listinfo/javascript>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20060619/b8ab0774/attachment.htm>


More information about the Javascript mailing list