ActionScript 2: setTimeout call a function with a delay

Just in case you forgot how to call a function with a delay or with parameters in ActionScript 2 (as2).
If you are looking for the ActionScript 3 version see this post.
I will show you how to do that, it’s really simple:

// Create a variable to store the timeout id and call the setTimeout function
var my_timedProcess:Number
// Call the setTimeout function with : The function to call and the time in milliseconds,
my_timedProcess = setTimeout(my_delayedFunction, 2000);

function my_delayedFunction () {
    trace("my_delayedFunction");
}

var my_timedProcess2:Number
// You also can add parameters to the setTimeout. Just add parameters separated by commas
my_timedProcess2 = setTimeout(my_delayedFunctionWithParams, 3000, "fruits", "food");

// Then set your parameters in your function.
function my_delayedFunctionWithParams (arg1, arg2) {
    trace("my_delayedFunctionWithParams: "+arg1+ " "+arg2);
}

// If you want to stop the timeout use this line
// clearTimeout(my_timedProcess)

That’s all :)