RSS

TimerEvent with Actionscript 3

03 Jul

Using Timer

package
{

  import flash.display.Sprite;
  import flash.utils.*;
  import flash.events.*;
  public class Main extends Sprite{
    public function Main(){
        var timer:Timer = new Timer(1000);
        timer.addEventListener(TimerEvent.TIMER, onTimer);
        
        timer.start(  );
    }
    function onTimer(event:TimerEvent):void {
      trace(“on timer”);
    }
  }

}

———–Timer with limited interval—————-
package{
  import flash.display.Sprite;
  import flash.utils.*;
  import flash.events.*;
  
  public class Main extends Sprite{
    public function Main(){

        var timer:Timer = new Timer(10005);

    }
  }
}

—————————-Listening for Timer Events———————————–
package {
    import flash.display.Sprite;
    import flash.utils.*;
    import flash.events.*;
    public class Main extends Sprite {
        public static const TIMER_DELAY:Number = 1000;
        public var timer:Timer = new Timer(TIMER_DELAY, 10);

        public function Main() {
            timer.addEventListener(TimerEvent.TIMER, onTimer);
            timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
        }
        private function onTimer(event:TimerEvent):void {
            trace(“Tick.”);
        }
        private function onTimerComplete(event:TimerEvent):void {
            trace(“Ding!”);
        }
    }
}

Click here for More detail

 

 

 

 

 

 

 

 

 

Advertisements
 
Leave a comment

Posted by on July 3, 2011 in Action Script3

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: