Results 1 to 3 of 3

Thread: scramble image array Simple Controls Gallery

  1. #1
    Join Date
    Mar 2009
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default scramble image array Simple Controls Gallery

    1) Script Title: Simple Controls Gallery v1.3

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...plegallery.htm

    3) Describe problem:

    How is it possible to scamble the actual order of the image array in the simpleGallery?

    so image 2 is loading 1st, image 1 is loading 2nd, image 8 is loading 3rd, etc...

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    You can scramble the order of the images in the sense that what used to be the 1st image in the array is random each time, so is the 2nd, 3rd etc. In other words, the order associated with each image becomes randomized. Inside the .js file, add the line in red to the existing code:

    Code:
    	setting.imagearray.sort(function() {return 0.5 - Math.random()}) //scramble order of images
    	for (var i=0; i<setting.imagearray.length; i++){
    		preloadimages[i]=new Image()
    		preloadimages[i].src=setting.imagearray[i][0]
    		if (setting.imagearray[i][3] && setting.imagearray[i][3].length>setting.longestdesc.length)
    			setting.longestdesc=setting.imagearray[i][3]
    	}
    DD Admin

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    roytje9 (03-31-2009)

  4. #3
    Join Date
    Mar 2009
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your help.

Bookmarks

Posting Permissions

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