Browse > Home / Flash & As, Tutorials / Pause flash TimeLine …

| Subcribe via RSS

Pause flash TimeLine …

June 14th, 2006 Posted in Flash & As, Tutorials

So you want to pause the time line for lets say for 5 seconds , And you dont know how to do that YET , here is the code with the sample file :)

stop();

var nInterval = setInterval(Play, 5000);

function Play() {
clearInterval(nInterval);
gotoAndPlay(_currentframe+1);
}

so what does Every line mean …

stop();
//stop at your desired frame .

//Build the interval
// 1 second = 1000 milliseconds 1 x 1000
// setinterval(the-function , time[in milliseconds])

var nInterval = setInterval(Play, 5000);

/*function which will excute and clear the interval & Will play the next
Frame after 5 sec.*/

function Play() {
clearInterval(nInterval);
gotoAndPlay(_currentframe+1);
}

Files can be found @ Zainals

31 Responses to “Pause flash TimeLine …”

  1. Koen Says:

    Thanks a lot for this script! This was exactly what I needed for my website! It works perfect and keeps my website low in kb’s!

    Thanks again, Koen.


  2. Mohammed Zainal Says:

    Glad it helped someone somewhere ;) good to see ya arround .


  3. schande Says:

    thnx mate, always handy to be able to stop the timeline. good script. cheers,


  4. Mohammed Zainal Says:

    hey schande , tnx for dropping by and leaving & leaving a comment .
    its been a while since i last posted anything about flash (”soon i will “) .


  5. Kombo Says:

    THx, this was exactly what I was looking for


  6. Mohammed Zainal Says:

    cheers bud , good site you got there but you need a preloader …
    i will post a video tutorial about Preloaders … so watch this space ..


  7. Sue Meyer Says:

    This info was a Godsend! I couldn’t find anything like it in the regular training sites.


  8. Mohammed Zainal Says:

    tnx sue , good 2 have ya around .


  9. Kiki Says:

    Awesome script. Simple and effective.


  10. Mohammed Zainal Says:

    cheers kiki .


  11. Andrew Says:

    You have saved me hours of work! Now I don’t have to adjust each layer.

    Thanks a lot!


  12. Mohammed Zainal Says:

    Hey Andrew ,
    cheers & welcome buddy !


  13. patrick brown Says:

    Any idea how to be able to turn the pausing on and off? I am trying to creat a slideshow that someone can play through (with the pause script pausing to show the pic), or turn the pause off and use the “next/previous” buttons. Make sense?

    -patrick
    ShadowDetails.com


  14. Mohammed Zainal Says:

    i dont exactly get it , but i think what you need is a boolean value …

    eg ,
    var en:boolean = true ;
    // compare
    if(en == true) {
    // actions to do pausing
    }else{
    //actions to next/previous
    }

    u can use a button to change the value of your boolean variable …


  15. smita Says:

    i have given interval to my animation. it automatially goes to next scene after that interval. but now i want to add a stop button to it. even if i say stop (); on release event of the stop buttion, it does not stop. it goes to next scene after the specified interval
    can i get help for this


  16. Mohammed Zainal Says:

    hey buddy , you cant stop intervals by adding a stop(); event …
    you have to kill your interval …

    e.g
    clearInterval(ID of your Interval );


  17. penelopy Says:

    Thank you have copy pasted your script. Have yet to try it out.
    Will get back to you


  18. Duncan Says:

    works like a dream. thank you so very dare you….


  19. David Says:

    mad script…simple, effective, makes you wonder why there isnt a pause function within flashes own set.

    thanks!!!


  20. Andy Says:

    Thanks for that reply so quick..

    Mate this is embarassing - im so new to all this……

    Try this: http://www.andypdavies.co.uk/images/clueless.jpg


  21. Andy Says:

    ^^ So for example I have put that code on the first frame assuming it will pause for 5 seconds..


  22. Mohammed Zainal Says:

    eyh , nothing is embarassing matey …
    anyway i see you are using flash CS3 , and looks like it has found a duplicate of functions , 2 or more functions exists in the scoop … so it conflicts which function to use …

    check layer 8 ? or seek where have you added the code twice within a movieclip …
    you can explore your movie’s actions by clicking on Window on the main menu then click on Movie Explorer …


  23. Andy Says:

    Cheers Mohammed,

    Im still a tad confused tho.. All I did was paste your code into the top layer (layer 8 renamed to ‘a’) to try and get each quote to pause before the next. I have uploaded a screenshot of the movie explorer like you advised:

    http://www.andypdavies.co.uk/images/movieexplorer.jpg


  24. Mohammed Zainal Says:

    hey Andy …
    Im thinking this might be because your export settings are set to Actionscript 3.0 ?
    click on Publish settings and assign it to ActionScript 2.0 and re-try …

    Otherwise send it to me tomorrow morning and i will be glad to sort you out .


  25. Andy Says:

    You’re a genius :-) Thanks so much Mohammed it works fine now - I hope I can come back again and ask you for advice!

    Cheers mate,


  26. Mohammed Zainal Says:

    Agh Andy welcome matey , sure sure , your most welcome , btw you might wanna catch me on DesignersBlock forums ? Join us , you could learn more :)
    http://design.ersblock.com/forum/

    and that would be me

    http://design.ersblock.com/forum/index.php?action=profile;u=28


  27. Andy Says:

    Excellent - just registered and it looks like it’ll be a great resource for me! Definitely catch you soon mate, and thanks yet again ;)


  28. Eric Walton 9 / Edub9 Says:

    Hello all,

    I am using the code below to auto play a movie.

    _root.pauseCount = 0;
    function pause(pc)
    {
    if(_root.pauseCount == pc)
    {
    clearInterval(pauseInt);
    play();
    }
    else
    {
    _root.pauseCount++;
    }
    }
    pauseInt = setInterval(pause, 0, 300);

    stop();

    What my question is what code can I use on a button in order to stop and resume? I do not want to change the code above at all just add a seperate button on a different layer.

    Any help is greatly appreciated,

    Eric
    http://www.HollywoodFineART.com


  29. Matthew Says:

    Hey this code is great but I’m also trying to add a little button to Pause/play the slideshow I’ve built. Currently have some timeline script looking like this:

    playpause.playbtn.onRelease = function() {
    clearInterval(nInterval);
    _root.stop();
    this.nextFrame();
    }

    The button is nested in a movie clip on the main timeline which has 2 frames so I can switch between a play/pause button. Can’t seem to make it stop, would really appreciate some advice!

    Cheers
    Mat


  30. trumoc Says:

    Hi
    About this codes to pause the timeline
    Does this affect the main.swf if I’m loading a movie.swf into a holder_mc into the main.swf using loadMovie() with the code?

    thanks in advance

    trumoc


  31. Ruwan Dissanayake Says:

    hey bro tnx a lot for tat code, it helped me a lot with my website, now i can upload it soon, oh i have search for many sites for that simple interval function thnx bro a lot..
    and wish u all the best in ur work keep it up.
    god bless u..
    and byeeeeeeeee

    ps: i normally dont post replys for the post but this is big help to me;)


Leave a Reply