setInterval(function,timeout);
Calls function every timeout (in miliseconds). Returns intervalId.
clearInterval(intervalID);
Cancels an interval created by a call to setInterval().
Example:
function outoftime()
{
Edit1 = "Out of time";
clearInterval(interval1); // stop repeating this function
}
// set 2000 miliseconds timer (2000 ms = 2 seconds)
interval1 = setInterval(outoftime,2000);
Download source project here (1 kb)
- Launch Flash Designer and set movie dimensions 300 x 300.
- Create edit filed that will appear as Edit1
- Choose “Frame” > “ActionScript” and paste the example code.
- Set frame delay to stop (“Frame” > “Frame Delay”).
- Hit F9 to play the file




February 3, 2010 at 2:21 pm
ID = setInterval(Test, 10000);
clearInterval(ID);
stop();
this is not working!
function Test will be called even i cleared the interval straight-away after it was created.
is there any other way how to do it?