View Full Version : Can the Ultimate Fade-in slideshow be changed dynamically?

12-06-2007, 08:19 AM
1) Script Title: Ultimate Fade-in slideshow (v1.51)
2) Script URL (on DD):
3) Describe problem:
I want to change the displayed images dinamically. I'm working with ajax, so I'm not refreshing the hole page, just a part of it. I've tryed to chage the array of images depending on witch page you are on, but that doesn't work. I'm guessing I need to reinitialize everything. Can this be accomplished with the script, or do I have to change it?

Thanks in advanced!

12-06-2007, 02:45 PM
There are two main issues here, the second one of which might not matter for you, depending upon your setup. Each of these have other considerations that go with them, they are:

1 ) Once a slide show (there can be several on a page) initializes, it sets an internal variable to contain its images. So, changing the array that it was started with won't change the images it is using.

2 ) Each slideshow writes to the page as it is loading, creating and styling the 3 HTML divisions it needs to function. If you replace this with Ajax, it needs to be recreated, or already exist in the imported content.

If you are not replacing the slide show, but only other content on the page, and want to simultaneously change the array of images for the slide show, you only have to worry about #1 above.

For that (#1), each slide show records its instance as:


which means that the first slide show (if you have only one it is the first) on a page will be:


The second one will be:


ans so on. Each show records its images as:


So the first show's images are now kept track of in an array called:


It is this array you would want to replace in order to change that show's images.

I did say that there were other considerations. This is a multi-dimensional array (an array containing arrays), each entry contains image source, link, and target. The easiest way to replace the array is with another one that you already have defined that resembles this one in structure.

Another consideration is the image's dimensions. If the new set's are the same as the old set's, we don't need to worry about that.

The last issue relating to #1 is preloading. The show preloaded its images as it was initializing. It placed the preloaded images in an array:

this.postimages=new Array() //preload images
for (p=0;p<theimages.length;p++){
this.postimages[p]=new Image()

It is this array that the show will look to for the actual images. It will be:


You would need to preload the images from all possible additional arrays after the page has loaded and define them as this array at the same time that you change the other array, so that they will be available to the script when needed.

Preloading takes as long as loading though, so don't go overboard with the number of images or their byte size.

Now, I may have left something out (from #1, I did leave #2 hanging for the time being), hopefully not, and hopefully #2 won't be an issue with your setup. If you need more help:

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