Skip to main content
Participant
July 2, 2009
Answered

Simple Pause/Play/Resume in timeline not audio

  • July 2, 2009
  • 1 reply
  • 1447 views

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!!!

This topic has been closed for replies.
Correct answer Ned Murphy

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)


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;

     }

}

1 reply

Ned Murphy
Legend
July 2, 2009

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.

gabemottAuthor
Participant
July 2, 2009

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

gabemottAuthor
Participant
July 2, 2009

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)