2 Replies Latest reply on Sep 5, 2008 5:05 PM by pasta_Primavera

    Creating a timer function

      I need an event to fire at a periodic 1 second rate as long as the app is running.
      I looked at the examples and found this (see Below):

      I am pretty new to flex, so what got me puzzled is the "package". all I am looking for is to use this timer function and create use the event listener function to do my bidding. my code looks like this, but its a no go.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
      applicationComplete="TimerExample()" color="#060606" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#4B679F, #4B679F]">


      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.controls.Alert;
      import flash.utils.Timer;
      import flash.events.TimerEvent;
      import flash.events.Event;

      public function TimerExample():void
      var delay:uint = 1000;
      var repeat:uint = 300;
      var myTimer:Timer = new Timer(delay, repeat);

      myTimer.addEventListener(TimerEvent.TIMER, timerHandler);


      publicprivate function timerHandler(e:TimerEvent):void
      trace("We got here");




      package {
      import flash.utils.Timer;
      import flash.events.TimerEvent;
      import flash.display.Sprite;

      public class TimerExample extends Sprite {

      public function TimerExample() {
      var myTimer:Timer = new Timer(1000, 2);
      myTimer.addEventListener("timer", timerHandler);

      public function timerHandler(event:TimerEvent):void {
      trace("timerHandler: " + event);