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
- Create a movieclip called ”playpause”. Put this movieclip anywhere in your main movie.
- Create a button in this movieclips first frame, call this button ”pause”.
- Now go to frame two, create a keyframe and another button, call this one ”play”.
- 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.
- 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.
64 Comments
januari 6, 2008
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!
mars 15, 2008
I'm glad to hear it
mars 26, 2008
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".
mars 27, 2008
Exactly.
I should update the guide to include this… It's fun to see that it's getting read!
september 22, 2008
Simple and Great! Thanks.
november 25, 2008
Thanks!
Supersimple!
december 11, 2008
using flash is amazing way of expressing the beauty of your site, so its ok
december 16, 2008
So simple, and it works perfectly. Thanks for your great contribution to those of us in need of short & to the point tutorials.
december 21, 2008
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?
februari 20, 2009
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!
februari 20, 2009
You're welcome
februari 20, 2009
You're welcome
februari 27, 2009
thanx
mars 2, 2009
This is fantastic, thank you so much!
mars 13, 2009
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.
mars 22, 2009
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 7, 2009
Thanks so much, very useful
april 9, 2009
works perfectly.. finally a normal tutorial with no bs!! thanks alot!!
april 16, 2009
Great! Works perfectly.
april 17, 2009
works at stopping my timeline but not the movie clips and flv file i have in my timeframe…any ideas?
april 17, 2009
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 22, 2009
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 23, 2009
_root.nameOfMovieClip
may work and more functionable then _parent.nameOfMovieClip
maj 7, 2009
Thank You so much !
juni 11, 2009
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
juni 15, 2009
Thanks a lot! After trying several other methods; this appears to be the most simple and effective
juni 17, 2009
you are the greatest! why can't everyone share this kind of help all the time? seriously, you saved my day BIG TIME! thanks!!!!!
juni 17, 2009
Agreed, this blog post was sprung from the need of a simple solution.
juli 6, 2009
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!
juli 6, 2009
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!
juli 7, 2009
Good one mang.
juli 21, 2009
Very helpful! I'm trying to make flash slideshows to display my work in my portfolio and this was just life-saving!!!
THANK YOU! ^.^
juli 26, 2009
sorry this is not working properly..
juli 31, 2009
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!
augusti 4, 2009
That was really helpful. I was also pulling my hair out looking for a solution for this.
augusti 6, 2009
This is awesome! Thank you!!!
augusti 20, 2009
Oh wow! This is friggin awesome! ^___^
Thanks
september 20, 2009
Thanks a lot, You save my lot of time.
september 24, 2009
BRILLIANT! Simplicity is genious.
oktober 28, 2009
This works and it is WAY too easy. THANKS!
november 3, 2009
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 3, 2009
exactly what i need. many thanks.
november 4, 2009
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?
januari 21, 2010
Thanks sooooo much!!!!!! Have spent ages searching for a solution!!
januari 27, 2010
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.
februari 2, 2010
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
februari 8, 2010
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
februari 9, 2010
Thank you so much!! It's exactly what i need!
februari 27, 2010
THANK YOU SOOOO MUCH! Your tutorial drop kicked my button into working! You rock!
april 21, 2010
WOW!!! THANK YOU! Words alone are not enough. Just as the first comment said, I spent so long looking for this exact solutuion and it was nowhere. Only thing was just as someone pointed out I had to set the export settings to ActionScript 2.0 or it did not work.
april 22, 2010
Hi,
I've created a flash slideshow which is going over 16000 frames, so i've split the movie into two.
I'm loading the second movie at the end of main movie using "loadMovieNum".
I have the placed the play/pause button in the main movie. It works fine until the second movie loads. This is used to work in older version of Flash(Flash 8). I'm using CS4 now.
Do you have any workaround for this?
juli 5, 2010
Thanks a lot,
It was too easy ………
thanx again
augusti 11, 2010
Excellent!, I really find this usefull, thanks a lot
juni 7, 2011
excellent!! 100% useful!!! thanks!!!!
juni 21, 2011
I cannot express how helpful this has been.
Double thumbs up.
juli 19, 2011
wait, im confused. how do i make a button in the movieclip?button controls? im nt sure what to do. i have a video from my computer that i want to put on my webpage, and it plays, but has no pause or play button. am i at the right place?
augusti 9, 2011
This worked perfectly, for once I stumble upon a tutorial where the person actually helps, thankyou!
september 15, 2011
Hi,
Thanks so much for posting this script.
its saved me so much time.
Does anyone know how to pause an swf which includes animated movieclips and sound also?
Would be really helpful as i’m stuck?!
december 2, 2011
I would like to say a massive THANK YOU for this page. It has really helped.
On our staff intranet, we had a rotating banner, and I had two buttons which allowed you to flick between the next and previous banner. However people kept asking for a pause button, and because of this page, I have now successfully created a pause and play button on my banner which works successfully.
Thank you so so much
december 13, 2011
No problem! I’m glad this post still helps, and it’s surprising that simple things like these are not written much about elsewhere.
januari 19, 2012
can you please help me in scripting action of a button to play another swf file?
februari 4, 2012
The stop button works properly but after stop it is not play when we click on play button.
mars 11, 2012
I guess I’m a little late to the party, but this worked FANTASTICALLY! Thank you so much.
mars 25, 2012
ya its useful script…..
One Trackback
[...] angezeigt. Wenn ich dann nochmal klicke soll der Film weiterlaufen. Ich habe das hier gefunden: Flash Movie Controls – Play/Pause Button | Isaac Keyet aber das funktioniert leider nur mit AS2 und ich bin nicht fit genug in Flash, um das auf AS3 zu [...]