PDA

View Full Version : preloading test



allyson
Nov 6th, 2006, 12:08 AM
The following code preloads images in a slideshow, but I am not sure of how to test that the next image is actually ready for viewing. The slideshow, when activated on the website displays the 'Image ready' message when the images haven't preloaded. Can anyone help please.


for (i=0;i<numberslide.length;i++){
preloadit[i]=new Image(i)
preloadit[i].src=numberslide[i][0]
loader="Loading"
}
loader="Image ready"

Arty Effem
Nov 6th, 2006, 04:26 PM
The following code preloads images in a slideshow, but I am not sure of how to test that the next image is actually ready for viewing. The slideshow, when activated on the website displays the 'Image ready' message when the images haven't preloaded. Can anyone help please.


for (i=0;i<numberslide.length;i++){
preloadit[i]=new Image(i)
preloadit[i].src=numberslide[i][0]
loader="Loading"
}
loader="Image ready"That assigns the string "Image ready" to loader as soon as the loop finishes, and does not reflect the loaded status of anything. You could try something like this:

for (i=0;i<numberslide.length;i++)
{
preloadit[i]=new Image(i)
preloadit[i].onload=new Function("numberslide["+i+"][0].isLoaded=true;");
preloadit[i].src=numberslide[i][0];
}

if( numberslide[ currentIndex+1 ][0].isLoaded )
...
(Untested)

allyson
Nov 7th, 2006, 04:31 AM
Hi

Thank-you for your help. Could you have a look at the slideshow (here (http://www.transgender.co.nz/testing/slideshow8.htm)) . I am fairly new to javascript so I apologise for my lack of skills .

bye for now
Allyson