I’m not very experienced in Flash. I can do basic movies with tweens, some playback buttons and maybe one or two animations, but that’s pretty much it. For a recent project however, I had to do a pause button.
Now this might seem like an easy task, but it isnt. A pause button must both pause and play the video. I looked around the web for some easy solutions, but couldn’t come up with anything useful (although I’m sure there are guides for it out there, I just didn’t look hard enough..). This is what I came up with:
How to create a Play/Pause button in Flash
1. Create a movieclip called “playpause”. Put this movieclip anywhere in your main movie.
2. Create a button in this movieclips first frame, call this button “pause”.
3. Now go to frame two, create a keyframe and another button, call this one “play”.
4. Create another layer, call this layer “script”. Put the marker in the first frame and open Frame Actions. Type in “stop();”. Create another keyframe, and do the same thing again.
5. The buttons need some actionscripting too to be able to work. They need to both make the other button display and to play and pause our movie, which is the main target. I found a way to do this really easily. Click the button “pause”, and open Button Actions. Then type in:
on (release) {
gotoAndStop(2);
_parent.stop();
}
The first line displays the play button, the other one pauses the main movie. Select the other button, “play”, and type in:
on (release) {
gotoAndStop(1);
_parent.play();
}
Save the document, press Command+Enter (PC: CTRL+Enter) and make sure it works.
I hope you found the guide useful! Please leave a comment below and let me know what you thought.
January 6th, 2008 at 11:50 am
I hope you get this – I just want to say that I spent, literally, an hour looking through help files, and Flash user group sites and google searches and ask.com searches and the Adobe site and… well, just everywhere I could possibly think of to find this solution to this simple, simple problem. (make pause/play buttons for Flash main timeline) I found NOTHING until I came across your posting here, which is just exactly what I needed. So simple, and so, so hard to find. Thank you!
March 15th, 2008 at 7:54 pm
I'm glad to hear it
March 26th, 2008 at 10:32 am
Fantastic. Works exactly how I wanted it to! The only issue I had was that I was trying to put the actions on the frame, not on the buttons. That obviously didn't work. So, if anyone out there is as new as me, just be sure that your action panel says "Actions – Button" at the top, not "Actions-Frame".
March 27th, 2008 at 3:57 pm
Exactly.
I should update the guide to include this… It's fun to see that it's getting read!
September 22nd, 2008 at 1:29 am
Simple and Great! Thanks.
November 25th, 2008 at 12:23 pm
Thanks!
Supersimple!
December 11th, 2008 at 12:49 pm
using flash is amazing way of expressing the beauty of your site, so its ok
December 16th, 2008 at 4:41 am
So simple, and it works perfectly. Thanks for your great contribution to those of us in need of short & to the point tutorials.
December 21st, 2008 at 4:49 am
Isaac, thank you for the code.
Do you think there is a way to make the button go back to a play button once the movie has finished?
February 20th, 2009 at 9:28 am
I worry a little about the having the code spread around in different places in the movie clip, but it sure is simple. Thanks for sharing it!
February 20th, 2009 at 8:09 pm
You're welcome
February 20th, 2009 at 8:09 pm
You're welcome
February 27th, 2009 at 10:26 am
thanx
March 2nd, 2009 at 11:24 am
This is fantastic, thank you so much!
March 13th, 2009 at 6:47 pm
Excellent, thank you. I too flailed around looking for the answer in help sections & online without success.
One thing — if someone, like me, in their flailing inserted Pause and Play Behaviors, you must delete them or they will interfere with the button controls, and you will be driven bat-crap crazy when the buttons won't work.
March 22nd, 2009 at 3:18 pm
Very useful, but yet so simple.
I fully understand the script as well, so that I can try to create own timeline controlling stuff myself!
Great job!
April 7th, 2009 at 1:44 pm
Thanks so much, very useful
April 9th, 2009 at 2:46 pm
works perfectly.. finally a normal tutorial with no bs!! thanks alot!!
April 16th, 2009 at 8:29 pm
Great! Works perfectly.
April 17th, 2009 at 8:03 pm
works at stopping my timeline but not the movie clips and flv file i have in my timeframe…any ideas?
April 17th, 2009 at 8:06 pm
Unfortunately it can only pause the main timeline, I'm afraid.
Hope you get it working! And if you do, let me know and I'll put up a note about the solution.
April 22nd, 2009 at 11:32 am
Hi, this seemed like the perfect solution till I realised it wasn't pauseing other movie clips within the main timeline. As another new user to Flash I've got a feeling this requires a bit more complex bit of code, does anyone know how it's done?
April 23rd, 2009 at 12:52 am
_root.nameOfMovieClip
may work and more functionable then _parent.nameOfMovieClip
May 7th, 2009 at 11:05 pm
Thank You so much !
June 11th, 2009 at 2:24 pm
when i finished making the movie clip and tried to test it , it works fine for pausing the film but i cant make it play again??
please reply asap
June 15th, 2009 at 7:29 pm
Thanks a lot! After trying several other methods; this appears to be the most simple and effective
June 17th, 2009 at 4:57 pm
you are the greatest! why can't everyone share this kind of help all the time? seriously, you saved my day BIG TIME! thanks!!!!!
June 17th, 2009 at 5:06 pm
Agreed, this blog post was sprung from the need of a simple solution.
July 6th, 2009 at 11:21 am
Buttons change but they don't affect the movie. I've put my movie in a movieclip in a new layer under PlayPause layer. I've out loadMovie(movie,0); on movieclips frame. What have I done wrong? Help!
July 6th, 2009 at 11:46 am
Sorry, just re-read comments and realised that the movie must be placed in the main timeline not in a movieclip – works like a dream now! Many thanks!
July 7th, 2009 at 3:20 am
Good one mang.
July 21st, 2009 at 1:48 pm
Very helpful! I'm trying to make flash slideshows to display my work in my portfolio and this was just life-saving!!!
THANK YOU! ^.^
July 26th, 2009 at 6:14 pm
sorry this is not working properly..
July 31st, 2009 at 12:16 pm
thanks for this! really wanted this.. most of the stuff online tell you how to make two separate buttons and put the Stop and Play actions on it. lame.
thanks a million!
August 4th, 2009 at 11:00 pm
That was really helpful. I was also pulling my hair out looking for a solution for this.
August 6th, 2009 at 5:59 pm
This is awesome! Thank you!!!
August 20th, 2009 at 12:22 am
Oh wow! This is friggin awesome! ^___^
Thanks
September 20th, 2009 at 12:47 am
Thanks a lot, You save my lot of time.
September 24th, 2009 at 7:10 am
BRILLIANT! Simplicity is genious.
October 28th, 2009 at 5:55 pm
This works and it is WAY too easy. THANKS!
November 3rd, 2009 at 9:49 am
wonderful tutorial!!! Thankz for posting it.
I experimented and found that if the movieclip is placed inside another movieclip, then also the command works for that movieclip alone and not for the whole flash file. This is really excellent.
Thanks thanks a lot!!!
November 3rd, 2009 at 8:26 pm
exactly what i need. many thanks.
November 4th, 2009 at 9:59 pm
I am having a hard time following this..
I made a slide show and have the forward and back buttons working..
I want it to play automatically slowly and put a play pause button on as well.. Anyone know what i should do?
January 21st, 2010 at 8:27 am
Thanks sooooo much!!!!!! Have spent ages searching for a solution!!
January 27th, 2010 at 10:13 pm
This information was increadibly helpful. If you have Adobe Flash CS3, there is a control pannel called "Components". In this section, there are all the controls for making a movie pause/play. You only need to drag them to your movie. If you do not have this version the code above works great! Thanks again.
February 2nd, 2010 at 6:07 am
thanx mate…can we have a slider along side the button to control the movie clip….?? like it moves along with the movie and we can drag to any point and it starts the movie from that point??? if u can do it…it would be amazing
February 8th, 2010 at 8:03 pm
Excellent tutorial, took a bit to do as I was using Actionscript 3.0! You can't seem to use the Actions -Buttons command in AS3 only AS2, once the publish settings were changed no probs!
Many thanks
February 9th, 2010 at 12:32 am
Thank you so much!! It's exactly what i need!