PDA

View Full Version : scramble image array Simple Controls Gallery



roytje9
03-30-2009, 02:19 PM
1) Script Title: Simple Controls Gallery v1.3

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex4/simplegallery.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...

ddadmin
03-31-2009, 08:00 AM
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:


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]
}

roytje9
03-31-2009, 09:26 AM
Thanks for your help.