AS Frame Timing

Hi,

I have an animation that I want to change ever 10 second or so, is there some AS that will say when 10 second is up play a movieclip?

Thank,

-datapimp

setInterval

Why isn’t my code working?

stop();
setInterval(this, “nextFrame”, 5000);

:frowning:

depends on how you have things set up.

Here’s an example that I use:[AS]this.onLoad=function(){
ivalContainer10=setInterval(fader,40,container10);}
fader=function(clip){
clip._alpha++;
if(clip._alpha>99){
//trace(textClip._alpha)
clearInterval(ivalContainer10);
}
updateAfterEvent();
}
createEmptyMovieClip(“clipContainer10”,10);
clipContainer10.loadMovie(‘bannerText.swf’);
clipContainer10._x=55;
clipContainer10._y=30;
clipContainer10._alpha=0;

[/AS]

Well on my web site www.julianwilson.tk (soon to be .com) I have some images that need to wait about 10 seconds until they fade out, at the moment I have then where they just burn though ALL these key frames but that adds to the fla mess and adds size on the swf.

yeh, so? does that mean you’re going to try a new approach using setInterval(), or that you don’t understand how to apply setInterval()?

What I posted before could all go in frame 1. Part of the beauty of setInterval() is that it can eliminate all those tweens and keyframes (which is getting me in trouble because I never learned frame-based AS, but I need to build preloaders…doh.)

The thing to look for is creating a function that does something (like ‘fader’) to something else (‘container10’), set up an upper or lower limit condition to clear the interval object (‘ivalContainer10’) when its gone far enough. Until that point, smooth the interval activity with ‘updateAfterEvent()’. Since setInterval() is happening independently of the framerate, ‘updateAfterEvent()’ forces a screendraw even if the next frame hasn’t been clocked…thereby smoothing out what might otherwise be a more jerky response tied to the project’s actual framerate. Put it in or leave it out, it depends on what you’re looking to do…