Results 1 to 2 of 2

Thread: How to stop this Slideshow after 1 cycle?

  1. #1
    Join Date
    Aug 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to stop this Slideshow after 1 cycle?

    Here is a quick one. I have a great little slideshow script that I use, but it cycles indefinitely. I need it to cycle through once and then stop. What do I need to change and why? Here is the script in its entirety:

    // Set slideShowSpeed (milliseconds)
    var slideShowSpeed = 3000;
    // Duration of crossfade (seconds)
    var crossFadeDuration = 3;
    // Specify the image files

    var Pic = new Array();
    Pic[0] = 'nickelbys/LOUNGE1.jpg'
    Pic[1] = 'nickelbys/LOUNGE2.jpg'
    Pic[2] = 'nickelbys/LOUNGE3.jpg'

    // do not edit anything below this line
    var t
    var j = 0
    var p = Pic.length

    var preLoad = new Array()
    for (i = 0; i < p; i++){
    preLoad[i] = new Image()
    preLoad[i].src = Pic[i]
    }

    function runSlideShow(){
    if (document.all){
    document.images.SlideShow.style.filter="blendTrans(duration=2)"
    document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
    document.images.SlideShow.filters.blendTrans.Apply()
    }
    document.images.SlideShow.src = preLoad[j].src
    if (document.all){
    document.images.SlideShow.filters.blendTrans.Play()
    }
    j = j + 1
    if (j > (p-1)) j=0
    t = setTimeout('runSlideShow()', slideShowSpeed)
    }


    Thank you for any of your help, theMind-

  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

    Change this:

    if (j > (p-1)) j=0

    to this:

    if (j > (p-1)) return;

    Why? Well, when j is greater than the number of pictures minus one, all pictures have been viewed once. In the original code, this signaled a restart at zero for j but, you say you want the thing to end at that point. Using return; in a function exits it.
    - John
    ________________________

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

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
  •