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

Advertisements

Actions

Information

75 responses

21 10 2006
Koen

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

Glad it helped someone somewhere πŸ˜‰
good to see ya arround .

13 04 2010
Gregory

i have a slide show that stops at each slide for 12 seconds and then goes to the next frame and plays. Everything works fine when i just let it play, however if i use the buttons (1-8) to jump to another slide before the 12 seconds is up it messes everything up. and if i go to another scene it seems to mess those up as well. i feel like the actionscript for the slide show starts to override all other actionscript within the movie.

Any suggestions would be greatly appreciated.

P.S. the only side show is on the home page or root timeline. all other actionscript within the movie are just simple ones like “stop and on press goto”.

I was told that i may need to add a clearInterval to all the button actionscripts, but i dont know how.

18 11 2006
schande

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

19 11 2006
Mohammed Zainal

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

THx, this was exactly what I was looking for

6 12 2006
Mohammed Zainal

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

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

7 12 2006
Mohammed Zainal

tnx sue , good 2 have ya around .

16 12 2006
Kiki

Awesome script. Simple and effective.

10 01 2007
Mohammed Zainal

cheers kiki .

7 03 2007
Andrew

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

Thanks a lot!

7 03 2007
Mohammed Zainal

Hey Andrew ,
cheers & welcome buddy !

21 03 2007
patrick brown

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

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

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

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

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

6 05 2007
Mohammed Zainal

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

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

8 05 2007
Moody

Cheers budd …

22 05 2007
David

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

thanks!!!

22 05 2007
Mohammed Zainal

glad ya like it , i was wondering the same mate …
but there ya go … πŸ˜‰

23 05 2007
David

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

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

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

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

Thanks Mohammed I have replied to the new blog πŸ™‚

26 06 2007
AdN

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

26 06 2007
Mohammed Zainal

hey AdN cheers for the comments πŸ™‚
grazie , good to know i have readers from italy …

31 07 2007
Chris

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

dido what he said.

Thanks & Cheers

22 09 2007
Eric Walton 9 / Edub9

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

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

30 01 2008
Finwee

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

22 02 2008
Julie

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

8 05 2008
Kim

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

11 05 2008
ofir

thanks for a simple script and a great way

24 06 2008
Axauv

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

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

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

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

21 07 2008
Joel

many thanks.

3 08 2008
Ron Wolpa

As a 1st trial I employed the pause timeline code to control a movieclip (it changes texts @ every 5 seconds ) that is into another movieclip ,a kind of bulletin pop up which comes up , when the flash site opens.
The text timing works perfectly until the button to close the pop up is pressed , which is simply a on (release) {gotoAndPlay(13);} , to command the pop up mc to go to the last frame , on which the txt mc instance is not present.
Yet as the pop up mc closes , the main time of the main mc @ _level10 , starts over & over ; I noticed that it obeys the timing stablished on the code of text movie clip. Is there a way to fix this trouble??

9 08 2008
vijay

yes i too faced the same trouble, the button instances are overlapping the time stopped by the code kept and its not responding to some , i dont know y? here is what i have done…. all are in main stage.. i had stopped timeline for every 3 seconds and some buttons are there here and there to just from 1 place to other, when i click on the button when the code is working the next time the stop code( interval set to 3 sec) is not working and just playing normally. I dont know Y?

This is the problem i faced with the movieclip as Ron Wolpa (08:48:04) : said, so i placed all of them in main stage. still am getting this problem. can anyone help me solve this problem………?

5 09 2008
Jessica

Hello,

I also found the pause script to be very helpful! My only issue is when I loop my animation, the pause actions don’t seem to work anymore? They only work the first time the animation runs. Has anyone else found this to be a problem? Should I be using a special loop action to go with this particular pause code?

17 10 2008
Waqas

awesome..!

Thanks for the help! It helped me a lot! Cheers!

3 12 2008
Vahan

Hello,

My only issue is when I loop in diferente Scene its going to the original Scene frame. I replaced the “gotoAndPlay(_currentframe+1);” with “gotoAndPlay(“Scene 3″, 1);” and its not working. Is there a way to fix this.

Thanks

29 01 2009
d0m1n1k_

THX, U h3lp me a lot!
Mayby someDay I will help U!
CYa

8 05 2009
J Diesel

Thanks for the script! Words great for my looping banner.

19 05 2009
sriram

thx a lot.this is excatly i needed.

6 07 2009
Raine

I have tried a couple of pause codes from here and other sites. I have a question regarding them. I have a series of say 5 images with forward and back buttons on each of them. If i press a forward or back button a few times it seems to mess with the timing of this whole thing. So no longer will each of the 5 images pause for 4 seconds they will each have different random times. Is there a way to over come this ?

11 07 2009
fifi

Great ,thank you
Cheers from Sarajevo

19 07 2009
Matthew

Thanks. I’ve seen other versions of this but they have all been somewhat wrong. This one works great.

9 08 2009
Stuart

Hi
I’m a new Flash user and your code has helped me not only solve an imediate problem but also understand Flash AS2 a lot better – many thanks :o)
Stuart

10 08 2009
Zainal

Hello Stuart,

Glad to know that buddy, keep on rolling on flash and you’ll find that its all about logic, go to http://www.gotoandlearn.com for more video tutorials.

Z

25 09 2009
Douglas

This is awesome!
Thanks heaps for putting it up on the net…

Cheers
Douglas

26 09 2009
Hobert

Hey, how to make 2 scenes and after it ends. the first scene restarts at the begining but the 2nd scenes stop playing.

Kinda like this.
How to make 2 scenes, first and second scene play at the same time, then while at the end, the first scene restarts at the begining but the second stops playing again?

help please

25 10 2009
umair ahmed

thanks brother

10 11 2009
noelson

Zainal, thank you very much.peace

10 11 2009
noelson

Zainal, thank you very much.

20 11 2009
Dave

awesome. thanks.

27 11 2009
Ruth

Hi
I love your site, so helpful! Have been trying your script on how to pause a movie for a few seconds and it’s not working!!!! why!!!! I’ve copied your exact script into a blank keyframe on a new layer……what am I doing wrong? getting very impatient with this…..please help me!! Thanks

17 12 2009
Dave

Have a look at this to show how to very simply stop the timeline on the click of one button and start it again on the click of another. AS2
http://www.kirupa.com/developer/mx2004/pause.htm

4 03 2010
Adi

It’s 2010 and this post helped another person. Best regards πŸ™‚

4 03 2010
zainal

wow! Glad to know that Adi πŸ™‚

13 04 2010
Gregory

i have a slide show that stops at each slide for 12 seconds and then goes to the next frame and plays. Everything works fine when i just let it play, however if i use the buttons (1-8) to jump to another slide before the 12 seconds is up it messes everything up. and if i go to another scene it seems to mess those up as well. i feel like the actionscript for the slide show starts to override all other actionscript within the movie.

Any suggestions would be greatly appreciated.

P.S. the only side show is on the home page or root timeline. all other actionscript within the movie are just simple ones like β€œstop and on press goto”.

I was told that i may need to add a clearInterval to all the button actionscripts, but i dont know how.

9 05 2010
dennis

so helpful, just what i was looking for!! thanx so much!

30 06 2010
the REAL Sean Rawles

This script is actually AMAZING, but it does make Flash do funky things in many browsers…

22 07 2010
chris

Thanks, just what i need for pausing my animation.

10 08 2010
Tomas

That is a piece of a good code. Hope the will be more of that comming soon. Thx

23 02 2011
Bryan

This was posted in 2006 and still we use it in 2011 this code is simple and works wonderfull thanks alot for it.

PS: Don’t delete this post in like ever lol

16 05 2011
Bryan

This was posted in 2006 and still we use it in 2011 this code is simple and works wonderfull thanks alot for it.

PS: Don’t delete this post in like ever lol

4 07 2011
catatansiodie

Thanks mate,,
it’s wonderful code..

28 07 2012
arun arya

Thanks dear,
It’s really good code…
once again thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: