Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : repeat loop


qberttt
5/24/2004 11:11:38 PM
Very new (today) to flash and action scripting... Experienced lingo programmer
and what I want to do in flash is to loop over a frame for say 10 seconds and
then advance without a user action. I have looked for an action to attach to
the sprite within a frame but not seeing the obvious I guess. What is the
best way to approach this. Thanks

Q
Jack.
5/24/2004 11:41:30 PM
this frame action is one (simple) method,

stop();

fps = 12; // movie speed
secs = 10;
frames = fps*secs;
tick = 0;

this.onEnterFrame = function(){
tick++;
tick %fps ? trace(int(tick/12)+"sec") : null;
if(tick == frames){
trace("time up");
play();
delete this.onEnterFrame;
}
};
qberttt
5/25/2004 1:07:05 AM
Thanks Jack, that's exactly what I needed. Much appreciated...

Flash Nick
5/25/2004 2:24:08 AM
Hi,

This could be done with less code using setInterval

stop();

setInterval(myFunction,10000);

function myFunction()
{
play();
Flash Nick
5/25/2004 2:30:12 AM
Flash Nick
5/25/2004 3:12:39 AM
You might want to clear that interval too.... otherwise it'll keep going off
every 10 seconds. So here's the revised version....

stop();

myInterval = setInterval(myFunction,10000);

function myFunction()
{
clearInterval(myInterval);
play();
}
AddThis Social Bookmark Button