PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
HOW DO YOU SIMPLY "PAUSE" THE PLAYHEAD for a few seconds?
A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: HOW DO YOU SIMPLY "PAUSE" THE PLAYHEAD for a few seconds?

  1. #1
    Junior Member
    Join Date
    Nov 2003
    Posts
    10

    HOW DO YOU SIMPLY "PAUSE" THE PLAYHEAD for a few seconds?

    Let's say you wanted to simply pause the PLAYHEAD with actionscript, and then start the playhead again automatically, after, say, 5 seconds??? Is there a way to do that, assuming nothing else is going on in your flash movie during that time...and I DON'T want to add 5 seconds worth of blank keyframes???

    hkampr@yahoo.com
    Last edited by Luka Bratzi; 07-31-2004 at 08:46 PM.

  2. #2
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Define a pause function on the first frame of your movie...

    code:

    function pause(){
    play();
    clearInterval(timer);
    };



    Then on any frame you want to pause the main timeline, just add the following...
    code:

    stop();
    timer = setInterval(pause, 5000);
    //where 5000 is 5 seconds or 60000, 1 minute.


  3. #3
    Junior Member
    Join Date
    Nov 2003
    Posts
    10

    Works Perfectly

    Thanks, that AS works perfectly!

  4. #4
    Junior Member
    Join Date
    Apr 2004
    Posts
    17

    Question

    If one wanted it to stop the music 'n' seconds into the song instead of pause, wouild I just leave the 'timer' part out.

    If so, would this then be the end of that play and they would have to re play to get the song again?

    Also is the whole song uploaded into the browser cache or can one have only a part of the song taken into the cache.

    Thanks

    oz

  5. #5
    Junior Member
    Join Date
    Nov 2001
    Posts
    2

    Sweet

    this works great / thanks a lot!

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    1
    oldnewbie...u rock...

    thanks for the code. awesome!

  7. #7
    Senior Member
    Join Date
    Mar 2010
    Posts
    157

    Question similar problem

    what if you have a 2d game like alien hominid, and you want to exit to a pause menu by clicking a button, whilst still being able to return to the game as it was just before you paused it? (like a 'resume' button in the pause menu)

    i figured i might just multiply everything with a number that i make 0 when the game is paused, and 1 when it's running. however, that's very messy. is there any other way to do this?
    should i store all the in-game data in an array and load that array whenever i exit the menu? that's also a lot of work, especially if i want the array to be compatible with any in-game situation.

    so my question is:
    how on earth do i do this???

    thank you.

  8. #8
    Junior Member
    Join Date
    Apr 2010
    Posts
    6
    Alternatively you can also try TimelineMax by the same people behind TweenMax.
    http://www.greensock.com/timelinemax/

    It's a beastly class platform!

  9. #9
    Senior Member
    Join Date
    Mar 2010
    Posts
    157
    looks great. what exactly are you suggesting? Do you think this program will sove my problem? thanks.

  10. #10
    Junior Member
    Join Date
    Apr 2010
    Posts
    6
    Quote Originally Posted by koenahn View Post
    looks great. what exactly are you suggesting? Do you think this program will sove my problem? thanks.
    Oldnewbie's code will work, and if you're happy with it then that's cool. But what TimelineMax does is gives you the ability to do a whole lot more, like reversing the timeline animation, or stop it, or do something crazy like yo-yo; which loops the animation between the starting frame and ending frame (think of a conveyor belt). It's really quite amazing what you can do with it.

  11. #11
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    it also prevents you from understanding what you're doing. On another hand, i wouldn't know how to build a car from scratch...

    gparis

  12. #12
    Senior Member
    Join Date
    Mar 2010
    Posts
    157
    something like this?

    Actionscript Code:
    function endPause():Void{
        play();
        clearInterval(timer);
    }
    function pauseThaGame():Void{
        stop();
        timer = setInterval(endPause(),*int*);
    }
    if(Key.isDown(*pausekey*)){
        pauseThaGame();//pauses the game for *int* millisecs
    }

    but it wil pause the app for a certain interval, not until a button is being pressed, and that's not what i want to do at all.
    Besides, it will stop the entire flash app, instead of just pausing the game. i want a controllable pause menu to pop up, you know. if the app is being paused, the menu won't work either, will it?


    danke shön.

  13. #13
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Just use stop() and play() if its the timeline you want to pause on button actions.

    It really depends on WHAT you want to stop:
    To stop an enterFrame loop, use:
    delete this.onEnterframe;
    To stop a setInterval use:
    clearInterval();
    To stop a function from executing the next block of code use:
    break;

    The list goes on.

    gparis

  14. #14
    Senior Member
    Join Date
    Mar 2010
    Posts
    157
    delete this.onEnterframe; ?
    niceee!
    i didn't know it existed!
    i'm going to put all of my funcs inside of the onEnterFrame, except the ones controlling the pause menu! wooot!
    thank you VERY much!!

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