IsaacKeyet

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.

61 Comments

  1. Steve Wertheimer

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

  2. Isaac Keyet

    March 15, 2008

    I'm glad to hear it

  3. Carrie

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

  4. Isaac Keyet

    March 27, 2008

    Exactly.

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

  5. Achim

    September 22, 2008

    Simple and Great! Thanks.

  6. Andre

    November 25, 2008

    Thanks!

    Supersimple!

  7. TestSEO

    December 11, 2008

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

  8. Jeff

    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.

  9. Chris

    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?

  10. Michael

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

  11. Isaac Keyet

    February 20, 2009

    You're welcome :)

  12. Isaac Keyet

    February 20, 2009

    You're welcome :)

  13. raju

    February 27, 2009

    thanx

  14. jean

    March 2, 2009

    This is fantastic, thank you so much!

  15. Bjornv

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

  16. Tommy

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

  17. David

    April 7, 2009

    Thanks so much, very useful

  18. Dustin

    April 9, 2009

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

  19. Hanna

    April 16, 2009

    Great! Works perfectly.

  20. erika

    April 17, 2009

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

  21. Isaac Keyet

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

  22. Colin

    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?

  23. wildhawk

    April 23, 2009

    _root.nameOfMovieClip

    may work and more functionable then _parent.nameOfMovieClip

  24. Ivo

    May 7, 2009

    Thank You so much !

  25. help

    June 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

  26. Saskia

    June 15, 2009

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

  27. basementboy

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

  28. Isaac Keyet

    June 17, 2009

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

  29. De66ie

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

  30. De66ie

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

  31. Danno

    July 7, 2009

    Good one mang.

  32. AthenasAngel

    July 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! ^.^

  33. Rahul Kr singh

    July 26, 2009

    sorry this is not working properly..

  34. Hash Milhan

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

  35. Jon

    August 4, 2009

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

  36. Shawn

    August 6, 2009

    This is awesome! Thank you!!!

  37. Inami4

    August 20, 2009

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

  38. Sudhir

    September 20, 2009

    Thanks a lot, You save my lot of time.

  39. KErkko

    September 24, 2009

    BRILLIANT! Simplicity is genious.

  40. Dan

    October 28, 2009

    This works and it is WAY too easy. THANKS!

  41. pinky

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

  42. ar281180

    November 3, 2009

    exactly what i need. many thanks.

  43. Christine

    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?

  44. Sascha

    January 21, 2010

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

  45. Groovy Chick

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

  46. Prerak

    February 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

  47. LesPix

    February 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

  48. Melo

    February 9, 2010

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

  49. Alex

    February 27, 2010

    THANK YOU SOOOO MUCH! Your tutorial drop kicked my button into working! You rock!

  50. Grateful User

    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.

  51. Prakash

    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?

  52. Himanshu VErma

    July 5, 2010

    Thanks a lot,
    It was too easy ………
    thanx again

  53. Eduardo

    August 11, 2010

    Excellent!, I really find this usefull, thanks a lot

  54. felix

    June 7, 2011

    excellent!! 100% useful!!! thanks!!!!

  55. Kira

    June 21, 2011

    I cannot express how helpful this has been.

    Double thumbs up.

  56. Jane

    July 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?

  57. Anonymous

    August 9, 2011

    This worked perfectly, for once I stumble upon a tutorial where the person actually helps, thankyou!

  58. Nathan

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

  59. Samantha Bailey

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

  60. Isaac Keyet

    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.

  61. dev

    January 19, 2012

    can you please help me in scripting action of a button to play another swf file?

One Trackback

  1. By Pause/Play Button - Flashforum on July 15, 2010

    [...] 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 [...]

Post a Comment

Your email is never shared. Required fields are marked *

*
*