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.
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!
I'm glad to hear it
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".
Exactly.
I should update the guide to include this… It's fun to see that it's getting read! 🙂
Simple and Great! Thanks.
So simple, and it works perfectly. Thanks for your great contribution to those of us in need of short & to the point tutorials.
Thanks!
Supersimple!
using flash is amazing way of expressing the beauty of your site, so its ok
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?
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!
You're welcome 🙂
You're welcome 🙂
thanx
This is fantastic, thank you so much!
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.
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!
Thanks so much, very useful
works perfectly.. finally a normal tutorial with no bs!! thanks alot!!
Great! Works perfectly.
works at stopping my timeline but not the movie clips and flv file i have in my timeframe…any ideas?
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. 🙂
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?
_root.nameOfMovieClip
may work and more functionable then _parent.nameOfMovieClip
Thank You so much !
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
Thanks a lot! After trying several other methods; this appears to be the most simple and effective 🙂
you are the greatest! why can't everyone share this kind of help all the time? seriously, you saved my day BIG TIME! thanks!!!!!
Agreed, this blog post was sprung from the need of a simple solution. 🙂
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!
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!
Good one mang.
Very helpful! I'm trying to make flash slideshows to display my work in my portfolio and this was just life-saving!!!
THANK YOU! ^.^
sorry this is not working properly..
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!
That was really helpful. I was also pulling my hair out looking for a solution for this.
This is awesome! Thank you!!!
Oh wow! This is friggin awesome! ^___^
Thanks
Thanks a lot, You save my lot of time.
BRILLIANT! Simplicity is genious.
This works and it is WAY too easy. THANKS!
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!!!
exactly what i need. many thanks.
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?
Thanks sooooo much!!!!!! Have spent ages searching for a solution!!
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.
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
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
Thank you so much!! It's exactly what i need!
THANK YOU SOOOO MUCH! Your tutorial drop kicked my button into working! You rock!
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.
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?
Thanks a lot,
It was too easy ………
thanx again