// setTimeout allows you to call a function after a specified delay along with arguments, which setTimer does not allow you to do
// You can even make it act like a loop if you call setTimeout within its called function
var dd:uint = 2000; // ms delay before function is called
var str:String = "Dog";
var mc:MovieClip = new MovieClip();
var timeoutExample:uint = setTimeout(delayedFunction, dd, str, "Cat", "Monkey", 0xFFDF1B, mc);
function delayedFunction():void
{
trace("Delayed function ");
if (arguments.length==0) {trace("No argumentys passed")};
for (var i=0; i<arguments.length; i++)
{
trace(arguments[i]);
}
timeoutExample = setTimeout(loopedFunction, dd/2, Math.round(Math.random()*100));
}
function loopedFunction():void
{
trace("Random number: "+arguments[0]);
timeoutExample = setTimeout(loopedFunction, dd/2, Math.round(Math.random()*100));
}