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 4 of 4
  1. #1
    New Coder
    Join Date
    Mar 2005
    Location
    Pennsylvania, USA
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preloader Not Working

    Can some of you check my code and see why it is not working? I have an array of images, and a function which should preload them. But alas, it does not. Here's the code:
    Code:
    var pics = new Array()
    	{			 	
    	pics[0] = "images/gallery/ff/ff1.jpg"
    	pics[1] = "images/gallery/ff/ff2.jpg"
    	pics[2] = "images/gallery/ff/ff3.jpg"
    	pics[3] = "images/gallery/ff/ff4.jpg"
            }
    function preloader() 
    	{
    	imageObj = new Image();
             for(i=0; i<total; i++) 
               {
                imageObj.src=pics[i];
    	   }
    	}

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    imageObj[i].src=pics[i];

    Edit: BTW... what the heh is total??
    That should be pics.length....
    Last edited by Willy Duitt; 06-03-2005 at 03:07 AM.

  • #3
    New Coder
    Join Date
    Mar 2005
    Location
    Pennsylvania, USA
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry, i didn't put that in there. total is a variable i put in which is pics.length.

    so, all i need to change is that one line? I'll give it a try.

  • #4
    New Coder
    Join Date
    Mar 2005
    Location
    Pennsylvania, USA
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, i think i have it working. i changed it to:
    Code:
    function preloader() 
      {
       for(i=0; i<pics.length; i++) 
        {
          imageObj[i] = new Image();
          imageObj[i].src = pics[i];
        }
      }


  •  

    Posting Permissions

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