Pause flash TimeLine …

14 06 2006

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


Actions

Information

42 responses to “Pause flash TimeLine …”

21 10 2006
Koen (07:27:57) :

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.

21 10 2006
Mohammed Zainal (09:49:37) :

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

18 11 2006
schande (23:26:57) :

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

19 11 2006
Mohammed Zainal (11:22:08) :

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

6 12 2006
Kombo (02:18:48) :

THx, this was exactly what I was looking for

6 12 2006
Mohammed Zainal (08:51:30) :

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

6 12 2006
Sue Meyer (22:36:59) :

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

7 12 2006
Mohammed Zainal (00:46:38) :

tnx sue , good 2 have ya around .

16 12 2006
Kiki (00:18:12) :

Awesome script. Simple and effective.

10 01 2007
Mohammed Zainal (01:32:47) :

cheers kiki .

7 03 2007
Andrew (02:15:57) :

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

Thanks a lot!

7 03 2007
Mohammed Zainal (07:44:46) :

Hey Andrew ,
cheers & welcome buddy !

21 03 2007
patrick brown (04:57:47) :

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

21 03 2007
Mohammed Zainal (08:27:27) :

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 …

2 04 2007
smita (10:02:28) :

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

2 04 2007
Moody (10:35:38) :

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

e.g
clearInterval(ID of your Interval );

6 05 2007
penelopy (13:51:53) :

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

6 05 2007
Mohammed Zainal (16:16:05) :

hey penelopy , thanks for dropping by , let me know if you need further help with that one …

I have moved to http://www.zainals.com/blog

8 05 2007
Duncan (04:46:36) :

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

8 05 2007
Moody (07:35:43) :

Cheers budd …

22 05 2007
David (07:00:10) :

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

thanks!!!

22 05 2007
Mohammed Zainal (10:01:07) :

glad ya like it , i was wondering the same mate …
but there ya go … ;)

23 05 2007
David (15:10:36) :

one thing i did notice though is that if you have audio with the movie, it can be a pain to work out the full length of the movie as the frame count doesnt take into account the pauses

clearly this is no ones fault (except perhaps Flash itself not having the pause function which would - or should - take into account those potential pauses)

anyway, once again, a great script :)

24 05 2007
Mohammed Zainal (07:51:57) :

hmmm , can you explain more ? i might be able to help mate …
btw i have moved to http://www.zainals.com/blog

here is the topic mentioned http://www.zainals.com/blog/2006/06/14/pause-flash-timeline/

13 06 2007
Andy (21:53:17) :

What am I doing wrong.. I am just trying to make text appear for 5 seconds, then different text and so on.. For a testimonials list…

I have inserted the above code into a layer i have set aside for actions and it gives me an error? :-(

13 06 2007
Mohammed Zainal (22:02:30) :

Hey andy … what kind of errors is that ?
Write it down and lemme have a look @ it …
please follow up on my new blog @ http://www.zainals.com/blog/2006/06/14/pause-flash-timeline/

13 06 2007
Andy (22:32:36) :

Thanks Mohammed I have replied to the new blog :-)

26 06 2007
AdN (16:03:00) :

Hey man…it works perfectly…that what i was looking for…cheers from Italy…

26 06 2007
Mohammed Zainal (21:07:28) :

hey AdN cheers for the comments :)
grazie , good to know i have readers from italy …

31 07 2007
Chris (00:32:54) :

Thanks for this script, It is amazing how complicaated some other scripters were making something that I as a beginner thought should be so easy.

Thanks very much

28 08 2007
PureDezigner (17:40:23) :

dido what he said.

Thanks & Cheers

22 09 2007
Eric Walton 9 / Edub9 (17:29:25) :

Below is another you can copy/paste into each (blank) keyframe in order to pause 3 seconds. It automatically resumes after.

Edub9

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

stop();

2 10 2007
Kamil Syed (19:37:59) :

Great code snipped. Before this, I had to insert 100s of frames to “pause”. Thanks!!!

30 01 2008
Finwee (20:41:05) :

Thanks a lot for this code! thats exactly what i search for!

22 02 2008
Julie (00:07:12) :

AWESOME!!!! I have been working on this for an hour…. that you so much for posting this code!

8 05 2008
Kim (03:51:49) :

This was exactly what I needed! Thanks so much. You saved me a lot of time!

11 05 2008
ofir (22:16:00) :

thanks for a simple script and a great way

24 06 2008
Axauv (23:02:45) :

who needs to pause for x seconds? i’m not sure where i’d use that. what i DESPERATELY need and for some reason can’t find on google ANYWHERE lol… is just how to put a very, very simple PAUSE button in my flash application. i don’t mind if i have to paste the code into every single movie clip i’m running, but there has GOT to be a way to pause a movie clip when you hit a button… not stop, but PAUSE it (so it freezes on whatever frame it’s on). then you hit the button again, and it plays from where it left off. simple!! how have the gods at Adobe made this so difficult? anyway, any tips appreciated!

3 07 2008
trumoc (12:51:27) :

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

10 07 2008
Bhanu (15:11:39) :

The code doesn’t seem to work if the code is inserted in the 2nd scene. It works only in the 1st scene. How do I go about?

18 07 2008
Ricardo Rubio (10:30:18) :

Hi thanks for publishing this bit of code, it was very helpful!
Warm regards,
Ricardo

21 07 2008
Joel (03:40:33) :

many thanks.

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>