Welcome to my actionscript snippet library!

Actionscript Snips is a small repository of actionscript code that aims to save developers and designers time when developing a website.  

setInterval

Code snippet that calls a function after one second intervals and stops when the counter limit is reached.

import flash.display.Sprite;
import flash.utils.*;

var duration:Number = 1000;
var intervalId:uint;
var counter:uint = 0;
var endCount:uint = 10;

intervalId = setInterval(myFunction, duration, "start");

function myFunction():void {
trace(arguments[0]);

counter++;
if(counter == endCount) {
trace("end");
clearInterval(intervalId);
}
}

0 comments:

Post a Comment