6 Replies Latest reply on Feb 16, 2010 9:48 AM by Ned Murphy

    How do i make a picture gallery run automatically?

    Fedebazo

      HI:

       

      I have a gallery that shows pictures when yo hit a next and previous button, but id like to make it go automatically.

      This is the code im using:

       

      stop();

      next_btn.onRelease = function() {
      if (_root._currentframe == 5) {
        gotoAndStop (1);
      }
      else {
      nextFrame();
      }
      }
      prev_btn.onRelease = function() {
      if (_root._currentframe == 1) {
        gotoAndStop (5);
      }
      else {
      prevFrame();
      }
      }

        • 1. Re: How do i make a picture gallery run automatically?
          waterdad568 Level 3

          When you say automatically, are you refering to playing the swf without user event, like pressing a button? If so all that code is a mute point. Stop() and gotoAndStop are just that, stopping the playhead. So to play automatically as I understand you, simply remove all stops and or use gotoAndPlay in your functions instead.

          • 2. Re: How do i make a picture gallery run automatically?
            Fedebazo Level 1

            OK i understand.

             

            So what i should do is simply remove the stops and use gotoAndPlay. And for delaying the pictures just insert frames in the layer were the pictures are located?

            What if i want to add a autoplay button (for on and off) and a next and previous button for people to look at the pictures at their own pace?

            • 3. Re: How do i make a picture gallery run automatically?
              waterdad568 Level 3

              The swf playhead is either playing or it is not. If you want it to play automatically then you do not use stop, if you want to allow the user to stop the playhead then you would use a stop function with a user driven event, a mouse or keyboard event.

               

              What you may want to look into, is a pause button, and or a button event like mouseOver and mouseOut, which would stop the playhead while the user hovers over the button and then resumes when focus is released. You can also code buttons to do just about anything you are looking for, stop, play, pause, previous frame, next frame, load something, unload something, and almost any combination thereof.

              1 person found this helpful
              • 4. Re: How do i make a picture gallery run automatically?
                Ned Murphy Adobe Community Professional & MVP

                What you can do is use the setInterval function to have it automatically advance from one image to the next with a time delay to allow for viewing the images.  Your current controls can remain as they are, but using them call on the clearInterval() function so as to stop the interval.  So you could have a play button that initiates the setInterval() call, and the previous/next buttons would use the clearInterval() call to stop it.  If you had a pause button, that too could clear the interval.

                 

                Your function that the setInterval would call would be similar to the code for your next button code.

                • 5. Re: How do i make a picture gallery run automatically?
                  Fedebazo Level 1

                  Thanks!

                   

                  Would it be too much to ask for a code example. Im new to actionscript.

                  • 6. Re: How do i make a picture gallery run automatically?
                    Ned Murphy Adobe Community Professional & MVP

                    You already have your button code in place, and as I mentioned, your next button code will be what you'll want in the function that setInterval calls.  Being new to actionscript, you'll do yourself a favor to gain some competency in using the help documents from the start.  Just look up the setInetrval() function and it will explain how it works and how to use it, possibly providing example code.  But if the help documents don't provide enough info in a way you can understand, searching Google is the next stop... between those two tools I manage to solve just about anything when it comes to learning new things in Flash.