How do you make timeouts

Hello guys I was wondering how could you make a timeout like to stay on a frame for x time and then after that time you get sent to another frame

Do the same as the following topic, but instead of moving, just do project.gotoAndStop(frame)

ok thanks!

I didn’t understand :| :sweat_smile:

can’t you use setTimeout

Try to put at the default the following:

this.FPSCounter = 0;
this.interval = 2*project.framerate;

onEvent('update', function () {
    if(this.FPSCounter++ >= this.interval) {
        project.gotoAndStop(2);
    }
});

That will change the frame after 2 seconds…
If you want a different time, just change this
“2” for the desired number in seconds…

this.interval = 2*project.framerate;

1 Like

ok I’ll try

wait how do I set the time

Change that number…

@Jovanny ok but for example if I wanted to stay for 35 seconds would I put 35 or 35000

35… it is already in seconds. You could do 0.5 for half of a second.

ok thanks! again…

Hi Jordy,

bit late to the party, but I wanted to share my code.
It is easy to make wick stop and start again - but it took my a few takes to get it to do this reliably, repeatedly and with precision.
in the default event

stop();
this.timer = Date.now()

in the update event

if ((Date.now() - this.timer) > 1000){ play() }

you can change the 1000 to any millisecond count you want.
I found this to be the most clean way of doing this :slight_smile:

regards,

Paul

2 Likes