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>

posted on 2009-06-16 00:59  timo.li  阅读(1970)  评论(0)    收藏  举报

导航