shapper a écrit :
> I think to preload an image I should us something like:
>
> img = new Image();
> img.src = 'images/img.jpg';
>
> Could someone tell me how to create a loop which would preload a list
> of images?
> Something like:
>
> ImagesFolder = '...';
> ImagesNames = '...';
>
> For i = 0 to ImagesNames.Count
> img = new Image();
> img.src = imagesFolder + imagesNames(i)
> End
imgs=["a.gif","../b.gif","http://example.com/imgs/c.gif" ...],pics=[];
function postLoad(k, max){
if(k<max) {
pic[k] = new Image();
pic[k].onload = function(){postLoad(k,max)};
pic[k].src = imgs[i];
k++;
}
}
onload = function(){ postLoad(0, imgs.length); };
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Contact :
http://stephane.moriaux.perso.wanadoo.fr/contact
ASM = Aimable Stéphane Moriaux = Amateur Sasseur Merdouilles