A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: how to make play/pause toggle button.

  1. #1
    Is there an easy way to make a button that toggles from play/pause? Or should I ask, what is the best way.

    thanks
    s

  2. #2
    Senior Member
    Join Date
    May 2002
    Location
    Sioux Falls, SD
    Posts
    1,155
    you can do

    on (release) {
    play ();
    }

    and

    on (release) {
    stop ();
    }

  3. #3
    Member
    Join Date
    Dec 2007
    Posts
    71

    Thank you!!!

    To skate342:

    Thank you so much, I really love you right now for saving my life with these button codes.

  4. #4
    Senior Member guardiankitty's Avatar
    Join Date
    Dec 2006
    Location
    Here
    Posts
    215
    If you wanted a single button that toggles between playing and not,


    Actionscript Code:
    on(press){
        if(playing){
            this.stop();
        }else{
            this.play();
        }
        playing=!playing
    }



    OUCHIE,... WOW this thread is back from good old 2002 tisk tisk anna_2010,

  5. #5
    Member
    Join Date
    Dec 2007
    Posts
    71

    Hmmmm...

    RE: "
    OUCHIE,... WOW this thread is back from good old 2002 tisk tisk anna_2010, "

    What do you mean by that guardianKitty?

    You obviously replied too! LOL But I have to say your timing couldn't have been more perfect! Thanks for your brilliant code also.

  6. #6
    Senior Member guardiankitty's Avatar
    Join Date
    Dec 2006
    Location
    Here
    Posts
    215
    Quote Originally Posted by anna_2010 View Post
    RE: "
    You obviously replied too!....
    Thanks for your brilliant code also.
    When your right your right,

    And no problem, hope it helped !

    -GK

  7. #7
    TheFlashMaster
    Join Date
    Aug 2009
    Posts
    28
    Now we are 2010, the first post is in 2002... and this post is still on the top of my list of threads... amazing !!!

  8. #8
    Junior Member
    Join Date
    Nov 2010
    Posts
    1
    Hey, can you help me do that but with two button images (play and pause) and toggle them?

  9. #9
    Registered User
    Join Date
    Aug 2011
    Posts
    1
    Hi, I'm new to html, and coding in general.. really hanging for a Dreameaver Catalyst..

    Is there a way I can apply this code to html?
    just to play/pause via a text button?

    Quote Originally Posted by guardiankitty View Post
    If you wanted a single button that toggles between playing and not,


    Actionscript Code:
    on(press){
        if(playing){
            this.stop();
        }else{
            this.play();
        }
        playing=!playing
    }

  10. #10
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    hey people ive got a problem im hoping you can help me solve im trying to make a pause button and im not very good with action script ive made a attempt but it still comes up with two errors can anyone help me get read of them here is the code ive being devolping.

    stop();
    var interval:Number = setInterval(function () {
    trace(interval);
    play();
    clearInterval(interval);
    }, 24000);

  11. #11
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    Your code works for me, if you want it to execute once after 24 secs, just use "setTimeout(functionName,24000);"

    Other than that i don't see what you need help with essentially.

  12. #12
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    thanks i knew i was close

  13. #13
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    still one error message ive now got it to this piont
    on (release) {
    stop();
    var interval:Number = setInterval(function () {
    trace(interval);
    play();
    clearInterval(interval);
    "setTimeout(functionName,1000);//" ;
    }})

    and the error message that comes up is

    **Error** Scene=Scene 1, layer=pause, frame=20:Line 8: ')' or ',' expected
    }})

    Total ActionScript Errors: 1 Reported Errors: 1

    can anybody give me a hand with that and thanks i dont mean to be a pain.

  14. #14
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    I don't know what you are trying to do middles, but try this:

    Actionscript Code:
    onRelease=function() {
    stop();
    function functionName(){
    trace(interval);
    play();
    clearInterval(interval);
    var interval=setInterval(functionName,1000);
    }
    }

  15. #15
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    ok that works and im making a duke box just had trouble with my pause button the rest is fine thanks for your help and if you need any in the future ill be happy to help

  16. #16
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Nice! Glad I've helped you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center