Bahrain

Pause flash TimeLine …

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

Related posts:

  1. ActionScript Idle Timer , Can be used as a screen Saver.

40 Responses to “Pause flash TimeLine …”

  1. On October 21, 2006 at 7:27 am Koen responded with... #

    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. On October 21, 2006 at 9:49 am Mohammed Zainal responded with... #

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

  3. On November 18, 2006 at 11:26 pm schande responded with... #

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

  4. On November 19, 2006 at 11:22 am Mohammed Zainal responded with... #

    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. On December 6, 2006 at 2:18 am Kombo responded with... #

    THx, this was exactly what I was looking for

  6. On December 6, 2006 at 8:51 am Mohammed Zainal responded with... #

    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. On December 6, 2006 at 10:36 pm Sue Meyer responded with... #

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

  8. On December 7, 2006 at 12:46 am Mohammed Zainal responded with... #

    tnx sue , good 2 have ya around .

  9. On December 16, 2006 at 12:18 am Kiki responded with... #

    Awesome script. Simple and effective.

  10. On January 10, 2007 at 1:32 am Mohammed Zainal responded with... #

    cheers kiki .

  11. On March 7, 2007 at 2:15 am Andrew responded with... #

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

    Thanks a lot!

  12. On March 7, 2007 at 7:44 am Mohammed Zainal responded with... #

    Hey Andrew ,
    cheers & welcome buddy !

  13. On March 21, 2007 at 4:57 am patrick brown responded with... #

    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. On March 21, 2007 at 8:27 am Mohammed Zainal responded with... #

    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. On May 21, 2007 at 11:57 pm smita responded with... #

    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. On May 21, 2007 at 11:58 pm Mohammed Zainal responded with... #

    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. On May 21, 2007 at 11:58 pm penelopy responded with... #

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

  18. On May 21, 2007 at 11:58 pm Duncan responded with... #

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

  19. On May 21, 2007 at 11:59 pm David responded with... #

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

    thanks!!!

  20. On June 13, 2007 at 12:16 pm Andy responded with... #

    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. On June 13, 2007 at 12:17 pm Andy responded with... #

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

  22. On June 13, 2007 at 1:04 pm Andy responded with... #

    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

  23. On June 13, 2007 at 1:24 pm Andy responded with... #

    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,

  24. On June 13, 2007 at 2:03 pm Andy responded with... #

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

  25. On June 13, 2007 at 12:52 pm Mohammed Zainal responded with... #

    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 …

  26. On June 13, 2007 at 1:20 pm Mohammed Zainal responded with... #

    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 .

  27. On June 13, 2007 at 1:29 pm Mohammed Zainal responded with... #

    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

  28. On September 22, 2007 at 7:36 am Eric Walton 9 / Edub9 responded with... #

    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. On January 8, 2008 at 8:00 am Matthew responded with... #

    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. On July 3, 2008 at 2:52 am trumoc responded with... #

    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. On August 8, 2008 at 1:45 am Ruwan Dissanayake responded with... #

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

  32. On October 26, 2008 at 7:48 pm Patrick Cavan Brown responded with... #

    I’m using the code above to pause a timeline creating a slideshow. Rollover buttons take the user back and forth through two different slideshows. After going back and forth once or twice, the pausing malfunctions. Even stop commands in the timeline quit working. I’ve included an example link below so that you can see for yourself… does anyone know how to fix this? I am stumped. thank you!!

    http://shadowdetails.com/galleries/indexmenu.swf

  33. On January 7, 2009 at 5:22 pm Martin responded with... #

    You, my friend, are a lifesaver. The only trouble I had was that I was using a button set to skip forward or backward along my timeline to certain “product areas” on our company site. When i did this with your code, the timing of the pauses was inconsistent. Sometimes it would be 10 seconds (what I set it for). Other times it would be as little as 2 seconds.

    What I did was put the clearInerval(nInterval); into my button itself, so that each time it was clicked, the interval reset. It works perfectly.

    Thanks a million.

  34. On March 24, 2009 at 9:52 am Quandris responded with... #

    flawless! just what I was looking for, thanks man!

  35. On July 1, 2009 at 4:34 am Michael Monaghan responded with... #

    Thankyou God for creating ZAINALS!!!!!

    This script saved my life.

  36. On December 29, 2009 at 2:20 am partheepan responded with... #

    Code you given is really wonderful one, but i want this to be used in some more nearly in 3 place key frames, how can i please help in this

    stop();

    var nInterval = setInterval(Play, 5000);

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

  37. On January 17, 2010 at 4:26 pm greg responded with... #

    the code you have above works great for pausing the frame, except that i’m using it within a movie clip and it seems to be affecting my entire movie. Frames outside the movie, in different scenes are being affected in the same way.

    Help please.

  38. On June 24, 2010 at 12:25 pm grant responded with... #

    I’m loading the code into the main swf that is nested deep with in the loading swf. when I click on the main nav and go back and load the code again the timing is out of proportion. Is there any way to fix that?

    Thanks in advance.

  39. On December 6, 2010 at 1:03 pm aceartist responded with... #

    Thank you for this wonderful easy to use flash pause on frame code… YOU SAVED MY DAY :)

  40. On December 14, 2011 at 2:33 pm Naeem responded with... #

    Ha!, thanks allot fot this neat little script. Exactly what I was looking for bro!

Add your response