call a function after few seconds using the method setTimeout().
In a Flex app if you want to call a function after sometime (in seconds or hours) you can use the method setTimeout().The below def shows the use.
setTimeout(getmyName,3000);
Here the method setTimeout() calls the function getmyName after 3 sec in the execution flow.i.e when the line setTimeout reaches in the excution flow then the execution flow calls the function getmyName after 3 sec as mentioned in the method.
The below code example explains the need.
import mx.managers.PopUpManager;
import flash.utils.setTimeout;
import mx.controls.Alert;
private var alert:Alert;
private function init():void
{
alert=Alert.show(”Hai”,”Kumar”);
setTimeout(hidealert,3000);
}
private function hidealert():void
{
PopUpManager.removePopUp(alert);
}
Here the function init() is called at creationComplete of the app.And it alerts and then waits for 3 sec and closes the Alert window as we are using the setTimeout method and calling a function to close the Alert using the PopUpManager class.
The method setTimeout() can used as our need in the app.leave any comments for suggestions.