Timer para aplicação Flex

    postado por: Gregui Shigunov | Tags , |

    Exemplo de classe que executa um método a cada tempo


    <?xml version="1.0″ encoding="utf-8″?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="init();">

    <mx:Script>
    <![CDATA[
    import mx.controls.Alert;
    private var timer:Timer = null;

    private function init():void {
    this.timer = new Timer( (60 * 1000) , (60 * 2) );
    timer.addEventListener("timer", this.executa);
    timer.start();
    }

    public function executa(event:TimerEvent):void {
    Alert.show("Chamando método");
    }
    ]]>
    </mx:Script>
    </mx:Application>


    No exemplo, o método execute será chamado 120 (60 * 2) vezes a cada 60 segundos (60 * 1000) .

    Comments (0)

    Postar um comentário

     
    BlogBlogs.Com.Br