Bugtracking:

Flash Movie Controls – Play/Pause Button

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.

By Isaac Keyet Posted in Bugtracking, Flash, Personal, Tutorials, Web, Work

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

48 Responses to “Flash Movie Controls – Play/Pause Button”


  1. Steve Wertheimer Says:

    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!

  2. Isaac Keyet Says:

    I'm glad to hear it

  3. Carrie Says:

    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".

  4. Isaac Keyet Says:

    Exactly.

    I should update the guide to include this… It's fun to see that it's getting read! :)

  5. Achim Says:

    Simple and Great! Thanks.

  6. Andre Says:

    Thanks!

    Supersimple!

  7. TestSEO Says:

    using flash is amazing way of expressing the beauty of your site, so its ok

  8. Jeff Says:

    So simple, and it works perfectly. Thanks for your great contribution to those of us in need of short & to the point tutorials.

  9. Chris Says:

    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?

  10. Michael Says:

    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!

  11. Isaac Keyet Says:

    You're welcome :)

  12. Isaac Keyet Says:

    You're welcome :)

  13. raju Says:

    thanx

  14. jean Says:

    This is fantastic, thank you so much!

  15. Bjornv Says:

    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.

  16. Tommy Says:

    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! :D Great job!

  17. David Says:

    Thanks so much, very useful

  18. Dustin Says:

    works perfectly.. finally a normal tutorial with no bs!! thanks alot!!

  19. Hanna Says:

    Great! Works perfectly.

  20. erika Says:

    works at stopping my timeline but not the movie clips and flv file i have in my timeframe…any ideas?

  21. Isaac Keyet Says:

    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. :)

  22. Colin Says:

    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?

  23. wildhawk Says:

    _root.nameOfMovieClip

    may work and more functionable then _parent.nameOfMovieClip

  24. Ivo Says:

    Thank You so much !

  25. help Says:

    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

  26. Saskia Says:

    Thanks a lot! After trying several other methods; this appears to be the most simple and effective :)

  27. basementboy Says:

    you are the greatest! why can't everyone share this kind of help all the time? seriously, you saved my day BIG TIME! thanks!!!!!

  28. Isaac Keyet Says:

    Agreed, this blog post was sprung from the need of a simple solution. :)

  29. De66ie Says:

    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!

  30. De66ie Says:

    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!

  31. Danno Says:

    Good one mang.

  32. AthenasAngel Says:

    Very helpful! I'm trying to make flash slideshows to display my work in my portfolio and this was just life-saving!!!

    THANK YOU! ^.^

  33. Rahul Kr singh Says:

    sorry this is not working properly..

  34. Hash Milhan Says:

    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!

  35. Jon Says:

    That was really helpful. I was also pulling my hair out looking for a solution for this.

  36. Shawn Says:

    This is awesome! Thank you!!!

  37. Inami4 Says:

    Oh wow! This is friggin awesome! ^___^
    Thanks

  38. Sudhir Says:

    Thanks a lot, You save my lot of time.

  39. KErkko Says:

    BRILLIANT! Simplicity is genious.

  40. Dan Says:

    This works and it is WAY too easy. THANKS!

  41. pinky Says:

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

  42. ar281180 Says:

    exactly what i need. many thanks.

  43. Christine Says:

    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?

  44. Sascha Says:

    Thanks sooooo much!!!!!! Have spent ages searching for a solution!!

  45. Groovy Chick Says:

    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.

  46. Prerak Says:

    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

  47. LesPix Says:

    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

  48. Melo Says:

    Thank you so much!! It's exactly what i need!

Leave a Reply


In order to submit a comment, you need to mention your name and your email address (which won't be published). And ... don't forget your comment!

Comment Form