Results 1 to 7 of 7

Thread: Random Pic Question

  1. #1
    Join Date
    Jun 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Random Pic Question

    1) Script Title: Ultimate Fade In Slideshow v2.0-

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

    3) Describe problem: Within Ultimate Fade In Slideshow v2.0- there is an option for randomization of pictures.

    Is if possible to have Ultimate Fade In randomize two pictures out of three. Meaning, when viewing the slide show the first and forth picture are the same but the second and third are random.
    Ex: non-random/random/random/non-random/random/random/non-random and so on..

    TIA!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes. Do you mean random each rotation, or random each page load?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Random each rotation, but for every third picture be non-random (a static picture). So, you would have a static picture then random each rotation for two pictures then back to a static picture then random each rotation and so on...1 static pic, 2 random pics, 1 static pic, 2 random pics so on...

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, random is random, which means that sometimes you could get the same order two times in a row. And I suppose it wouldn't matter what order the images were in to begin with, but that could be randomized too.

    That said, there are two other aspects of this that are tricky.

    1. Since we will be shuffling at the end of each rotation, if the last image isn't a static one, it will jump to its new image. I put in some code that will enforce that the last image be static.

    2. I can't figure out why yet, but there must be an even number of images, otherwise there will be a blank image at the end of every other rotation.


    Here's an example initialization (addition highlighted):

    Code:
    var mygallery2=new fadeSlideShow({
    	wrapperid: "fadeshow2", //ID of blank DIV on page to house Slideshow
    	dimensions: [250, 180], //width/height of gallery in pixels. Should reflect dimensions of largest image
    	imagearray: [
    		["11l7ls0.jpg", "", "", "Nothing beats relaxing next to the pool when the weather is hot."],
    		["xp3hns.jpg", "http://en.wikipedia.org/wiki/Cave", "_new", "Some day I'd like to explore these caves!"],
    		["531q3n.jpg"],
    		["119w28m.jpg", "", "", "What a beautiful scene with everything changing colors."],
    		["stadium.jpg"],
    		["lakeside.jpg"] //<--no trailing comma after very last image element!
    	
    	],
    	displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
    	persist: false, //remember last viewed slide and recall within same session?
    	fadeduration: 500, //transition duration (milliseconds)
    	descreveal: "none",
    	togglerid: "",
    	onslide: function(curimage, index){
    		var ims = this.setting.imagearray, i = ims.length - 1;
    		if(index == i){
    			var statNums = [1, 3], $ = jQuery, stat = [], rand = [];
    			statNums.push(i + 1);
    			$(ims).each(function(i){
    				if($.inArray(i + 1, statNums) > -1){
    					stat[i] = this;
    				} else {
    					rand.push(this);
    				}
    			});
    			rand.sort(function(){return 0.5 - Math.random();});
    			for (i; i > -1; --i){
    				if(stat[i]){
    					ims[i] = stat[i];
    				} else {
    					ims[i] = rand.pop();
    				}
    			}
    			this.setting.$gallerylayers.html(fadeSlideShow.routines.getFullHTML(ims)).find('img').hide().eq(this.setting.curimage).show();
    		}
    	}
    })
    Don't miss the added comma (red) after the togglerid entry. The red numbers 1 and 3 assigned to the statNums array are the images that will be static, add as many numbers here as you like. 1 represents the first image and so on.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jun 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank You!

    I haven't been able to get your script to work. The pictures don't rotate in a random order. But I will continue to work on it. For a better idea on what I'm working please see below:

    Code:
    ["11l7ls0.jpg", "", "", "Nothing beats relaxing next to the pool when the weather is hot."],
    		["xp3hns.jpg", "http://en.wikipedia.org/wiki/Cave", "_new", "Some day I'd like to explore these caves!"],
    		["531q3n.jpg"],
    ["11l7ls0.jpg", "", "", "Nothing beats relaxing next to the pool when the weather is hot."],
    		["stadium.jpg"],
    		["lakeside.jpg"], 
    ["11l7ls0.jpg", "", "", "Nothing beats relaxing next to the pool when the weather is hot."],	              
    		["lakeside.jpg"],
                    ["lakeside.jpg"] //<--no trailing comma after very last image element!
    
    And so on.....
    Red=Static (create a Static Folder/copy&paste 11l7ls0.jpg to that folder)
    Blue=Random (create a Random Folder/copy&paste the rest of the images)

    Anytime an image is picked from the Random folder it should be a random pick.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I tested this rather extensively. The code you provide in your post only reveals the local names (I'm assuming of some) of the images you want displayed. It doesn't show me anything I can use to diagnose why you are not getting the result you want.

    If you want more help:

    Please post a link to a page on your site that contains the problematic code so we can check it out.


    As a side note, I was playing with the code a bit more, and it can be set up so that every third image is static, the rest shuffled on each rotation, regardless of how many images there are, without any need to specify the statNum array.

    But lets not get ahead of ourselves. First lets see if we can figure out why this isn't working for you.

    Give me a link to the problem page and I will check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jun 2010
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I just got back to working on this and I was able to resolve the error and both were cuased by me.

    1) make sure to copy the entire code
    2) wait one rotation before the pictures are random ( I was thinking that it would be random the first time around)
    3) and did I mention that it really helps when you copy the entire code

    Thank You...u-da-man!

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
  •