Search Flex Components Free

Custom Search

December 27, 2007

Flex Timed Alert Example

Creat a New mxml file:

timedAlert.mxml

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”
http://www.blogger.com/ “ layout=”vertical” verticalAlign=”middle” backgroundColor=”white”>
<!– creationComplete=”init()” –>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.managers.PopUpManager;
private var myAlert:Alert ;
/*
public function init():void
{
myAlert = Alert.show(”My Alert”);
this.addChild(myAlert);
var myTimer:Timer = new Timer(1000,1);
myTimer.start();
myTimer.addEventListener (TimerEvent.TIMER_COMPLETE,callComplete);
}
public function callComplete(event:TimerEvent):void{
this.removeChild(myAlert);
}
*/
private function showAndHide(delay:Number):void {
var alertText:String = “I'm an Alert control. I'll disappear in ” + (delay / 1000).toFixed(1) + ” seconds.”;
var alertTitle:String = “Timed Alert”;
myAlert = Alert.show(alertText, alertTitle);
setTimeout(hideAlert, delay);
}
private function hideAlert():void {
PopUpManager.removePopUp(myAlert);
}
]]>
</mx:Script>
<mx:Button label=”Launch alert” click=”showAndHide(3000);” />
</mx:Application>

Related Flex Tutorials