6 Replies Latest reply on Jul 2, 2009 5:28 PM by Ned Murphy

    Simple Pause/Play/Resume in timeline not audio

    gabemott

      So sorry if this is simple. I HOPE it is simple, it should be simple.

      I have a very simple looping timeline. I just want to create a TOGGLE function so that the user can pause and resume. Like a freeze frame. Or the space bar in some movie editing programs. Simple PAUSE.

      http://colorisrelative.com/RichMedia/templateROTATING.swf

       

      Everything I find for pause is a pause for a defined duration-- then it resarts on its own.

      I want to pause on the current frame and restart on the current frame when the user clicks.

       

      (or I keep finding stuff for video and audio). I am hoping there is real simple solution. I am really bad at actionscript. The following is the exent of my knowledge of actionscript:

      (click to start)

      http://colorisrelative.com/RichMedia/template3as2moosh.swf

      So thank you for letting me know if there is a simple pause/play toggle function!!!

        • 1. Re: Simple Pause/Play/Resume in timeline not audio
          Ned Murphy Adobe Community Professional & MVP

          To pause a timeline you simply use stop();  To resume playing you simply use play();

           

          For the second example you showed it appears to toggle between doing two things.  If you show the code you used for clicking for that, it may be easy enough to adapt to the pause/resume scenario you want.  Even if it isn't, it will at least reveal some code you are familiar with that may make it easier to show you a way.

          • 2. Re: Simple Pause/Play/Resume in timeline not audio
            gabemott Level 1

            Thank you Ned for the response. Maybe I shouldn't have included the second example. That was just to show off how poor my skills are.

             

            I appreciate the simple responses, but I don't know how to put stop () and play () into the timeline such that the user could click a button (or just the entire area) and the play would stop if it was playing and it would start if it was stopped; a toggle as such. I think I need to figure out some if/else statements, but I was just hoping there was a command that would simply toggle play on or off.

             

            I'd like the user to be able to click on the shapes and the animation would freeze. Then click again and it would keep going from where it left off. Sorry if this is not a simple question.

             

            Here's the link to the file again that I want to allow the user to freeze and start.

            http://colorisrelative.com/RichMedia/templateROTATING.swf

            • 3. Re: Simple Pause/Play/Resume in timeline not audio
              gabemott Level 1

              P.S. since you asked to see the code, here's the code from the second example. The first example, the one I am concerned with has no code yet.

               

              on (release) {
                  gotoAndPlay(2);
              }

               

              (that's set up for a button that covers the whole area)

              • 4. Re: Simple Pause/Play/Resume in timeline not audio
                Ned Murphy Adobe Community Professional & MVP

                Thanks for showing the code you understand.  For what I'll offer, the approach is to use a variable that keeps track of what state the movie is in (paused or playing) and use that variable to decide how to make it the opposite of what it currently indicates.

                 

                On the timeline create a variable:  var pausePlay = false; // this is if the movie starts plyaying right away without clicking anything

                 

                Create a button that covers the whole stage like you did for the second exmple.  Add this code to the button:

                 

                on(release){

                     if(pausePlay){

                          play();

                          pausePlay = false;

                     } else {

                          stop();

                          pausePlay = true;

                     }

                }

                • 5. Re: Simple Pause/Play/Resume in timeline not audio
                  gabemott Level 1

                  Mr Ned Murphy: Thank you so much. I knew there had to be a simple way to make it work.

                  Here's a new one with your code inserted.

                  http://colorisrelative.com/RichMedia/templateROTATINGballoon.swf

                  Brilliant toggle as far as I am concerned.

                  I did put in the first code, but it didn't seem to work to keep the movie from starting right away. I'll probably just insert one key frame before everything and do a start button that jumps to frame 2 to get into the loop. I tried to put in your one line of code in the timeline on a bunch of different layers.

                   

                  Anyway, thank you so much.