PASZ.COM LABS

Thursday, June 14, 2007

Preloading Images in JavaScript

Ok, this may be old news for some people, but since I'm working in Flash about 90% of the time these days, I'm always looking for tricks to make my life easier when I have to do JavaScript stuff. Here's a function that will preload an array of images:

function imagePreLoad(images)
{
    var image = new Array();

    for (var i = 0; i < images.length; i++)
    {
        image[i] = new Image();
        image[i].src = images[i];
    }
}


Now here's a question: Is it possible to update the progress of the download or fire a callback when it's complete, like you can do in Flash?

14 Comments:

Post a Comment

<< Home