Tuesday, February 8, 2011

Timer Example

<?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" minWidth="955" minHeight="600" >
    <fx:Script>
        <![CDATA[
            import flash.events.TimerEvent;
           
            import mx.controls.Alert;
            import mx.events.FlexEvent;
           

            protected function onButtonClick():void
            {
                Alert.show("application1_creationCompleteHandler");
                var tim1:Timer=new Timer(1000, 5);
                tim1.addEventListener(TimerEvent.TIMER_COMPLETE,timComplete1);
                tim1.start();
            }

            protected function timComplete1(ev:TimerEvent):void
            {
                (ev.target as Timer).stop();
                Alert.show("timComplete1");
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Button x="453" y="164" label="Button" click="onButtonClick()"/>
</s:Application>

No comments:

Post a Comment