4 Replies Latest reply on Jun 18, 2011 8:35 AM by perpor2

    AIR Timer()

    daslicht Level 2

      Hello,

      how can I make a Timer working in an AIR Application ?

       

      When I try to create a timer like var t:Timer = new Timer(1000) it sais that Timer do not expect more than 0 arguments ??

       

      I even tried created a external Class file but as far as I create an instance of it I get an error ... ??

        • 1. Re: AIR Timer()
          daslicht Level 2

          SOLVED

          • 2. Re: AIR Timer()
            perpor2

            how have you soldved ??? I have the same problem, thanks,,,,

            • 3. Re: AIR Timer()
              daslicht Level 2

              <?xml version="1.0" encoding="utf-8"?>
              <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                          xmlns:s="library://ns.adobe.com/flex/spark" 
                                          xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="windowedapplication1_creationCompleteHandler(event)">
                   
                   <fx:Script>
                        <![CDATA[
                             import flash.utils.Timer;
                             
                             import mx.events.FlexEvent;
                             [Bindable]
                             private var t:flash.utils.Timer = new flash.utils.Timer(1000);
                             
                             
                             
                             protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
                             {
                                  t.addEventListener(TimerEvent.TIMER, timer_handler);
                                  t.start();
                                  
                                  
                             }
                             private function timer_handler( e:TimerEvent):void
                             {
                                  trace(t.currentCount);
                             }
                             
                        ]]>
                   </fx:Script>
              </s:WindowedApplication>
              

               

              Importing import flash.utils.Timer; alone down not work !

               

              I dont know why it is not working, probably someone like to enlighten us.

               

              Funny thing is that in another project of mine its working instanttly without forcing the package like : t:flash.utils.Timer

              • 4. Re: AIR Timer()
                perpor2 Level 1

                thanks ! for my need I have also solved using the class getTimer(),

                 

                (really I was using the class Date(), but I was not able to set this class with the milliseconds...)