FORUMS: list search recent posts

setTimeout / clearTimeout

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Judson Larke
setTimeout / clearTimeout
on Jun 18, 2009 at 4:03:27 am

I'm trying to make a slideshow that slides every 5 seconds with setTimeout

I also want to be able to click buttons to move to certain frames, clear the timeOut, and then start the timeOut again so it keeps sliding every 5 seconds after you get there like it was before'

my slide code:

stop();
var timelineDelay:Number = 5;
clearTimeout(timelineDelay);
function wait() {
play(); // Just continue playing
trace("Timeline was delayed "+timelineDelay+" seconds, now continuing");
}
setTimeout(wait, timelineDelay*1000)

my button code:
one_btn.onRelease = function() {
clearTimeout(timelineDelay);
gotoAndPlay(1);
}


Can anyone help me fix this? It's driving me crazy.

Thanks in advance.


Return to posts index

Pieter Helsen
Re: setTimeout / clearTimeout
on Jun 18, 2009 at 7:10:21 am

Place all your photos in a container movieclip, give that movieclip an instance name and place it on the main timeline. (this way you only need one frame on your main timeline)

Then add this code:

var inter:Number = setInterval(goto, 5000);

function goto():Void {
my_mc.nextFrame();
}

// This is the action for your stop button
pauseBtn.onRelease = function() {
clearInterval(inter);
}


Timeout only runs your function once, interval runs it over and over.

Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Return to posts index

Judson Larke
Re: setTimeout / clearTimeout
on Jun 18, 2009 at 9:58:34 am

Awesome, got it to work great thanks for the quick reply!


Return to posts index


Pierrick Senelaer
Re: setTimeout / clearTimeout
on Sep 14, 2009 at 10:15:47 am

Hi Guys,

I am trying to replicate the same slideshow where I have a a couple of videos and a couple of pictures but I seem to struggle a bit...

I have put the videos and the pictures in a movie clip and gave it an instance name. Within the movie clip, I have got this code for each frame where I have a video or a picture

stop();

var timelineDelay:Number = 5;
clearTimeout(timelineDelay);
function wait() {
if(_currentframe == 1)
gotoAndPlay(3);
play(); // Just continue playing
trace("Timeline was delayed "+timelineDelay+" seconds, now continuing");
}
setTimeout(wait, timelineDelay*1000)

It scrolls automatically after 5 seconds. I just can't work out how to make it stop (and make it start again) if the user click on any of the scrolling buttons of the navigation.

I hope you huys can help

Thanks

P


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]