<?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" viewSourceURL="srcview/index.html">
	
	<mx:Script>
		<![CDATA[
			import flash.utils.clearTimeout;
			import mx.controls.Alert;

			private var alert:Alert;
			private var timeoutID:uint;

			private function delayedAlert():void {
				timeoutID = setTimeout(launchAlert, 2000);
				startBtn.enabled = false;
				cancelBtn.enabled = true;
			}

			private function launchAlert():void {
				alert = Alert.show("I'm an alert.");
				startBtn.enabled = true;
				cancelBtn.enabled = false;
			}

			private function cancelAlert():void {
				clearTimeout(timeoutID);
				startBtn.enabled = true;
				cancelBtn.enabled = false;
			}
		]]>
	</mx:Script>

	<mx:Button id="startBtn"
			label="Click here to launch alert (2 second delay)"
			click="delayedAlert();" />

	<mx:Button id="cancelBtn"
			label="Cancel alert!"
			enabled="false"
			emphasized="true"
			color="red"
			themeColor="red"
			click="cancelAlert();" />

</mx:Application>

