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

October 21st, 2006 at 7:27 am
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.
October 21st, 2006 at 9:49 am
Glad it helped someone somewhere
good to see ya arround .
November 18th, 2006 at 11:26 pm
thnx mate, always handy to be able to stop the timeline. good script. cheers,
November 19th, 2006 at 11:22 am
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 “) .
December 6th, 2006 at 2:18 am
THx, this was exactly what I was looking for
December 6th, 2006 at 8:51 am
cheers bud , good site you got there but you need a preloader …
i will post a video tutorial about Preloaders … so watch this space ..
December 6th, 2006 at 10:36 pm
This info was a Godsend! I couldn’t find anything like it in the regular training sites.
December 7th, 2006 at 12:46 am
tnx sue , good 2 have ya around .
December 16th, 2006 at 12:18 am
Awesome script. Simple and effective.
January 10th, 2007 at 1:32 am
cheers kiki .
March 7th, 2007 at 2:15 am
You have saved me hours of work! Now I don’t have to adjust each layer.
Thanks a lot!
March 7th, 2007 at 7:44 am
Hey Andrew ,
cheers & welcome buddy !
March 21st, 2007 at 4:57 am
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
March 21st, 2007 at 8:27 am
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 …
May 21st, 2007 at 11:57 pm
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
May 21st, 2007 at 11:58 pm
hey buddy , you cant stop intervals by adding a stop(); event …
you have to kill your interval …
e.g
clearInterval(ID of your Interval );
May 21st, 2007 at 11:58 pm
Thank you have copy pasted your script. Have yet to try it out.
Will get back to you
May 21st, 2007 at 11:58 pm
works like a dream. thank you so very dare you….
May 21st, 2007 at 11:59 pm
mad script…simple, effective, makes you wonder why there isnt a pause function within flashes own set.
thanks!!!
June 13th, 2007 at 12:16 pm
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
June 13th, 2007 at 12:17 pm
^^ So for example I have put that code on the first frame assuming it will pause for 5 seconds..
June 13th, 2007 at 12:52 pm
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 …
June 13th, 2007 at 1:04 pm
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
June 13th, 2007 at 1:20 pm
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 .
June 13th, 2007 at 1:24 pm
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,
June 13th, 2007 at 1:29 pm
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
June 13th, 2007 at 2:03 pm
Excellent - just registered and it looks like it’ll be a great resource for me! Definitely catch you soon mate, and thanks yet again
September 22nd, 2007 at 7:36 am
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
January 8th, 2008 at 8:00 am
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
July 3rd, 2008 at 2:52 am
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
August 8th, 2008 at 1:45 am
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;)