A dica Flex de hoje é para aqueles que nos últimos dias me perguntaram sobre como fechar automaticamente uma janela depois de um certo período de tempo. Para esse exemplo criamos um Alert que será fechado após 5 segundos. Veja o código a seguir:
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <fx:Script> [CDATA[ import mx.controls.Alert; import mx.managers.PopUpManager; ? private var notificatorTimer:Timer; private var myAlert:Alert; ? [Bindable] public var timeDestroy:Number = 5000; ? ? private function startTimer(event:MouseEvent):void { notificatorTimer = new Timer(timeDestroy, 1); notificatorTimer.addEventListener( TimerEvent.TIMER_COMPLETE, remove_handler); notificatorTimer.start(); myAlert = Alert.show( "Aguarde, serei fechado em 5seg ...", "MyAlert"); } ? ? private function remove_handler(event:TimerEvent):void { PopUpManager.removePopUp(myAlert); } ? ]]> fx:Script> ? <s:Button label="Abrir Alert" click="startTimer(event)" /> ? s:Application> |
Espero que tenham gostado. Até a próxima!




O Zend AMF é uma implementação feita em 












