Sunday, November 4, 2007

Javascript load Images

So I couldnt quite get the solution Joebert gave me to work last time so I went and did some quick searching, I found a gallery script made in javascript that loads images as its displaying them. Its like what Joebert suggest to me but instead of loading all the images at once in an external js file, this loads one and then loads another, in a loop. However Im no javascript expert and Im not really sure how it all works.

What I can figure out is in the comments, after that Im not really sure whats going on.

CODE:

ads=[]; ct=0; duration = 4;

function switchAd() {
//?
var n=(ct+1)%src.length;

// Check to see if the next-image-to-be-displayed is loaded, if it is then switch to the image.
if (ads[n] && (ads[n].complete || ads[n].complete==null)) {
document["Ad_Image"].src = ads[ct=n].src;
}
//?
ads[n=(ct+1)%src.length] = new Image;
ads[n].src = src[n];
//Set a timer on the function so to wait, basicly makes it so the image has to display for duration seconds.
setTimeout("switchAd()",duration*1000);
}



Topic Replies: 0

Read More...

[Source: Ozzu - Posted by FreeAutoBlogger]

No comments: