FLEX:使用setTimeout,setInterval ,实现sleep功能

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/02/15/creating-timers-using-the-settimeout-method/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">

<mx:Script>
<![CDATA[
import mx.controls.Alert;

private var alert:Alert;

private function delayedAlert():void {
setTimeout(launchAlert, 2000);
button.enabled = false;
}

private function launchAlert():void {
alert = Alert.show("I'm an alert.");
button.enabled = true;
}
]]>
</mx:Script>

<mx:Button id="button"
label="Click here to launch alert (2 second delay)"
click="delayedAlert();" />

</mx:Application>

你可能感兴趣的:(SetInterval)