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
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts

    preloading image function

    hello
    i would like to know if this preloading image function is correct, e.g: it does the work it is supposed to do.

    Code:
    function Load(){
      var photoNames = ["over0","over1","over2","over3","over4","over5","over6","over7","over8","over9","over10",
    "over11","over12","over13","over14","over15","over16","over2","over17","over18","over19","over20","over21",
    "over22","over23"];
    var photoObjects = [];
    for (var i = 0; i < photoNames.length; i++)
      {
        photoObjects[i] = new Image();
        photoObjects[i].src = 'images/collection/' + photoNames[i] + '.jpg';
      }
    }

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by sybil6 View Post
    hello
    i would like to know if this preloading image function is correct, e.g: it does the work it is supposed to do.
    It doesn't because the data is stored in a temporary variable, which is deleted as soon as the function terminates.

    Code:
    /*****************
    
    Image Preloader that allows any common path and/or file extension to be specified once only.
    
    Usage:
    
     new Preloader( common path or "", common extension or "").init( filename[,filename]... ));
    
    Examples.
    1) Preload a group of files from the current folder.
    
     new PreLoader().init('pic1.png', 'pic2.gif', 'pic3.jpg');
    
    2) Preload a group of .jpg files stored in /images/
    
      new PreLoader('/images/', '.jpg').init('pic1', 'pic2', 'pic3');
    
    If a common path or extension is specified, it must not be included in the filenames.
    
    *****************/
    
    function PreLoader(path, extn)
    {
     this.holder = [/*53637269707465726C61746976652E636F6D*/];
     this.path = path || "";
     this.extn = extn || "";
    
     this.init = function()
     { 
      for(var i=0, len=arguments.length; i<len; i++)
      {
       this.holder[i] = new Image();
       this.holder[i].src = this.path + arguments[i] + this.extn;
      }
     }
    }

  • #3
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts
    thank you im going to try this function for my rollovers, looks quite neat.


  •  

    Posting Permissions

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