2 Replies Latest reply on Aug 4, 2008 10:43 PM by rykkardo8

    problems with a slideshow

    rykkardo8
      I am a complete actionscript newbie and I made this slideshow:
      http://www.lagunalodgeatitlan.com/photos-en.html

      As you can see, the slideshow plays automatically and also has buttons to go back to the previous frame and next frame.

      I used 2 pieces of script for this file, the first is an interval of 5 seconds for each frame:

      stop();

      var nInterval = setInterval(Play, 5000);

      function Play() {
      clearInterval(nInterval);
      gotoAndPlay(_currentframe+1);
      }



      and the second is simple actions for the buttons to go to the next or previous frame.

      However if you try to use the buttons the slideshow goes crazy, skipping several frames at a time and so on.

      Any pointers on how ti fix this? I uploaded the .fla to
      http://www.lagunalodgeatitlan.com/slide2.rar

      Thanks a lot for your time.

      Kind regards,

      Ricardo
        • 1. Re: problems with a slideshow
          robdillon Most Valuable Participant
          You don't want to put this:
          var nInterval = setInterval(Play, 5000);

          function Play() {
          clearInterval(nInterval);
          gotoAndPlay(_currentframe+1);
          }
          into every frame. Just put it in the first frame where you want to use it. Then change it slightly to look like this:
          var nInterval = setInterval(Play, 5000);

          function Play() {
          if(_currentframe != _totalframes) {
          nextFrame();
          } else {
          clearInterval(nInterval);
          }
          }
          This will fix the running wild problem. However, you still have manual controls for next and previous. What you probably want to have happen is for the manual controls to stop the automatic play. To do that, you'll need to change your design slightly. You'll need to name the button instances and put the code for them in the same frame script space as you have the code above. Remove the code that's attached to the buttons. That code might look like this:
          • 2. Re: problems with a slideshow
            rykkardo8 Level 1
            Hi Rob,

            Thanks so much for your reply! It works like a charm!

            I believe my client wants the slideshow to resume after hitting next or prev. so I will wait for his comments before modifying the buttons' code.

            Kind regards,

            Ricardo