Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: preloading test

  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    Auckland, New Zealand
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    preloading test

    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"

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by allyson View Post
    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:
    Code:
    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)

  • #3
    New Coder
    Join Date
    Jun 2002
    Location
    Auckland, New Zealand
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Hi

    Thank-you for your help. Could you have a look at the slideshow (here) . I am fairly new to javascript so I apologise for my lack of skills .

    bye for now
    Allyson


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •