Copy link to clipboard
Copied
I am working on an interactive flash program for a gallery installation that will be running for two weeks. This interactive flash program has buttons that users that take users to various "pages," like a website. However, as this is a gallery installation, I want the program to reset to the Splash page after a certain amount of time has passed. I have had limited success with setInterval(). It works great the first time, and the delay is what I set it as (I set it as 10 seconds for this test). However on subsequent tries (ie, after it has reset to the Splash page, and I start the process again), the delay is only about 1 or 2 seconds. What is going on here? Why is the delay not consitent?
Here is my simple code:
function FlashReset1():void
{
gotoAndStop("SPLASH");
}
setInterval(FlashReset1,10000);
You are probably creating multiple instances of it and they end up all working and firing at different times. You need to clear the Interval using clearInterval each time.
You are probably better off using the Timer class, or you might even consider using the setTimeout function which doesn not repeat and does not need anything to clear it after it fires.
Copy link to clipboard
Copied
Looks like you never clear interval. Because it runs indefinitely next time you hit the code you shown - it may be any number because you most probably hit it in between.
Also, I suggest you use Timer instead of setInterval - it is cleaner and more manageable.
Copy link to clipboard
Copied
You are probably creating multiple instances of it and they end up all working and firing at different times. You need to clear the Interval using clearInterval each time.
You are probably better off using the Timer class, or you might even consider using the setTimeout function which doesn not repeat and does not need anything to clear it after it fires.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now