<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="init()">
<mx:Script>
<![CDATA[
import flash.events.TimerEvent;
import flash.utils.Timer;
private const WAIT_NUM_SECONDS:int = 3;
private var timer:Timer;
private function init():void {
timer = new Timer(1000, WAIT_NUM_SECONDS);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
okButton.enabled = false;
okButton.label = okButton.data + " (" + WAIT_NUM_SECONDS + ")";
}
private function onTimer(evt:TimerEvent):void {
var count:int = timer.repeatCount - timer.currentCount;
if (count > 0) {
okButton.label = okButton.data + " (" + count + ")";
} else {
okButton.enabled = true;
okButton.label = okButton.data.toString();
}
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:Button label="Reset button" click="init()" />
</mx:ApplicationControlBar>
<mx:Button id="okButton"
data="OK"
width="80" />
</mx:Application>