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
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.
Glad it helped someone somewhere 😉
good to see ya arround .
thnx mate, always handy to be able to stop the timeline. good script. cheers,
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 “) .
THx, this was exactly what I was looking for
cheers bud , good site you got there but you need a preloader …
i will post a video tutorial about Preloaders … so watch this space ..
This info was a Godsend! I couldn’t find anything like it in the regular training sites.
tnx sue , good 2 have ya around .
Awesome script. Simple and effective.
cheers kiki .
You have saved me hours of work! Now I don’t have to adjust each layer.
Thanks a lot!
Hey Andrew ,
cheers & welcome buddy !
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
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 …
hey buddy , you cant stop intervals by adding a stop(); event …
you have to kill your interval …
e.g
clearInterval(ID of your Interval );
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
Thank you have copy pasted your script. Have yet to try it out.
Will get back to you
works like a dream. thank you so very dare you….
mad script…simple, effective, makes you wonder why there isnt a pause function within flashes own set.
thanks!!!
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
^^ So for example I have put that code on the first frame assuming it will pause for 5 seconds..
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 …
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
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 .
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,
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
Excellent – just registered and it looks like it’ll be a great resource for me! Definitely catch you soon mate, and thanks yet again 😉
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
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
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
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;)
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
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.
flawless! just what I was looking for, thanks man!
Thankyou God for creating ZAINALS!!!!!
This script saved my life.
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);
}
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.
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.
Thank you for this wonderful easy to use flash pause on frame code… YOU SAVED MY DAY 🙂
Ha!, thanks allot fot this neat little script. Exactly what I was looking for bro!
Hey, I would like to pause/resume sound and timeline together, so when I pause my sound, the timeline stop also. Does anyone can help? Thanks!
here is the code i’m using to pause/resume my sound:
import flash.events.MouseEvent;
var resumeTime:Number = 0.00;
var mySound:Sound = new Butterfly_Waltz;
var channel1:SoundChannel = new SoundChannel();
pause_btn.addEventListener (MouseEvent.CLICK, pauseSound);
play_btn.addEventListener (MouseEvent.CLICK, playSound);
channel1 = mySound.play(70);
function pauseSound(e:MouseEvent):void
{
resumeTime = channel1.position;
channel1.stop();
pause_btn.visible = false;
play_btn.visible = true;
}
function playSound(e:MouseEvent):void
{
channel1 = mySound.play(resumeTime);
play_btn.visible = false;
pause_btn.visible = true;
}