声名一个方法
private function launchAlert():void {
Alert.show("I'm an alert.");
}
2秒后执行这个方法
flash.utils.setTimeout(launchAlert, 2000);
源码:
<?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>
flash.utils.setTimeout
最新推荐文章于 2026-06-26 10:34:46 发布
本文介绍了一种使用Flash的setTimeout方法实现延迟显示警告框的技术。通过具体代码示例展示了如何让警告框在用户点击按钮后的两秒延迟后出现,并在警告框关闭后使按钮重新变得可用。
82

被折叠的 条评论
为什么被折叠?



