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 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Which Preloader Array Script?

    Can somebody tell me which script below is better for preloading images? If you know of a better one or see something that could be changed to work better, please let me know.

    Code:
    function preloader() {
    
    	// Set array for rollover images
    	AllImages=new Array("image1.gif",
    			    "image2.gif",
    			    "bluecirc.gif",
    			    "greencirc.gif",
    			    "redcirc.gif",
    			    "blackcirc.gif"
    			   );
    	
    	for(loadall=0; loadall<AllImages.length; loadall++) {
    	
    		var LoadedImage=new Image();
    		LoadedImage.src=AllImages[loadall];
    	}
    
    }
    
    
    function preloader2() {
    	switchSection(1);
    	}
    
    	// Set array for rollover images
    	imag = new Array()
    	
    	// scroll arrow images
    	imag[0] = "image1.gif"
    	imag[1] = "image2.gif"
    	imag[2] = "image3.gif"
    	imag[3] = "image4.gif"
    	
    	// Preload images
    	if (document.images) {
    		im = new Array()
    			for (var i = 0; i < imag.length; i++){
    			im[i] = new Image()
    			im[i].src = imag[i]
    	}
    }

    John

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Spain
    Posts
    420
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think that second is better, as every image is assigned to a different variable, instead of using an unique one for all
    Don't resist to assimilation. Billions of Borgs can't be wrong!


  •  

    Posting Permissions

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