Newbie: Preloading Images question

S

Stephen Chalmers

Kevin Duggan said:
I am trying to get these Images to preload w/ no sucess.

There are plenty of examples of how to do this. You need to load the images into
an array of Image type objects, while your file names being sequential, do not
need to be in an array as they can be constructed in a for loop.

I think this should work:

var bnrCntr = 0;
var banners = new Array(4);

for(var i=0; i<banners.length; i++)
{
banners=new Image(320, 65);
banners.src='banner'+(i+1)+'.gif';
}

function bancycle()
{
if (bnrCntr == banners.length)
bnrCntr = 0;

document.images['Banner'].src = banners[ bnrCntr++ ].src;

setTimeout("bancycle()", 3000)
}
 
K

Kevin Duggan

Thanks Stephen;

I did look for some online tutorials and
they seem to be preloading.
I guess it is a bit elementary but
to me,... not.

Thanks for your help

Kevin
There are plenty of examples of how to do this. You need to load the images into
an array of Image type objects, while your file names being sequential, do not
need to be in an array as they can be constructed in a for loop.

I think this should work:

var bnrCntr = 0;
var banners = new Array(4);

for(var i=0; i<banners.length; i++)
{
banners=new Image(320, 65);
banners.src='banner'+(i+1)+'.gif';
}

function bancycle()
{
if (bnrCntr == banners.length)
bnrCntr = 0;

document.images['Banner'].src = banners[ bnrCntr++ ].src;

setTimeout("bancycle()", 3000)
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top