"Loading" Graphic (Preload issue)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stacey

    "Loading" Graphic (Preload issue)

    Hi,
    I'm hoping for a bit of advise-- I have a (relatively, from the
    point-of-view of this dilettante) complex script that attempts to preload
    certain images in order to trigger one of a series of six slideshows
    (rather than try to articulate, have a look here):



    Clicking any of the six blocks of text along the sides will begin a loop
    of the corresponding slideshow.

    Problem is, of course, there's a lot of loading here (blame the boss). It
    seems to run fine on broadband, but, of course, dialup users are getting
    broken images all over the place.

    The "loading" graphics before the slideshow are really a tease-- just four
    seconds of extra time to load the remaining images (not enough for
    dialup).

    My question is twofold:

    -- Any tips, pointers, tutorials on if it's possible to make those
    "loading" graphics functional loading graphics (e.g. rather than part of
    the array, they stay put until the images I want are actually loaded)?

    -or-

    -- Any advise on how to properly preload images? (I've read that the
    myriad examples we see of preload functions by way of calling the image is
    a bit of a misnomer).

    Any suggestions at all would be more than appreciated...
  • Vincent van Beveren

    #2
    Re: "Loading&q uot; Graphic (Preload issue)

    I coulnd't get your example to run, in Netscape it shows the document
    source (mime-type problem in the server?) and in explorer it gives
    errors. I can imagine that some people might not like the following
    code because of my misuse of arrays.

    var plImages;
    var pointer = 0;
    var preloader;

    function preload(filenam es) {
    if (preloader==nul l) {
    // cancel previous preloading
    window.clearTim eout(preloader) ;
    }
    plImages = filenames;
    pointer = -1;
    preloader = window.setTimeo ut("checkPreloa d();", 500);
    }

    function checkPreload() {
    // need to load next?
    if (pointer<0 || plImages[pointer].complete) {
    // increment pointer
    pointer++;
    // loaded all images?
    if (pointer>=plIma ges.length) {
    // call complete
    preloadComplete ();
    return;
    } else {
    // create other preloading image
    img = new Image();
    img.src = plImages[pointer]
    plImages[pointer] = img;
    preloadProgress (pointer);
    }
    }
    window.setTimeo ut("checkPreloa d();", 500);
    }

    function preloadComplete () {
    // fill this in
    }

    function preloadProgress (imagesLoaded) {
    // fill this in
    // for example:
    pg = document.getEle mentById("progr ess");
    pg.innerText = imagesLoaded+" of 6 images loaded";
    // or
    progressBlock = document.getEle mentById("pImag e"+imagesLoaded ");
    progressBlock.s rc = "fillblock.gif" ;
    }

    // call:
    preload(['image1.gif', 'images2.jpg', 'etc.gif']);


    once loaded preloadComplete is called. For every complete image
    preloadProgress is called.

    Comment

    Working...