4 Replies Latest reply on Jul 23, 2006 9:41 AM by inlineblue

    Creating a Timer to Display

    DARTHCYL0N Level 1
      okay I have had this working on and off today and not sure what the deal is . here is the pertinent code for it . does anyone have anything better (this is going into a flex app) or can someone tell me why I am getting the following error

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at VIPER30/::secondsHandler()
      at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
      at flash.utils::Timer/flash.utils:Timer::tick()

      Here is the pertinent code

      import flash.utils.Timer;
      import flash.events.TimerEvent;

      public var cs:Number;
      public var stationClock:Timer;

      //Set Clock times initial
      public function setClock():void
      cmo = 10;
      cd = 4;
      ch = 8;
      cm = 5;
      cs = 0;

      //This function loads data upoon the users login
      public function loadStartData():void{

      //Start Clock Functions for the Clocks
      public function runStationClock():void{
      stationClock = new Timer(1000, 60);
      stationClock.addEventListener(TimerEvent.TIMER, secondsHandler);
      stationClock.addEventListener(TimerEvent.TIMER_COMPLETE, oneMinuteTimerComplete);

      private function secondsHandler(event:TimerEvent):void{
      cSeconds.text = event.target.currentCount;

      public function oneMinuteTimerComplete(event:TimerEvent):void{
      cm = cm + 1;
      cminutes.htmlText = cm.toString();
      cm = cm - 1;
      cSeconds.htmlText = "0";

      <!--This is where the seconds display on the page-->
      <mx:AddChild relativeTo="{panel1}" position="lastChild">
      <mx:Label x="296" y="130" text="1" fontSize="20" width="42" textAlign="center" color="#8080ff" id="cSeconds"/>

      now after the error it comes up and starts counting but it seems to step back and then go forward , though counting up .
      anyone run into this problem

      Ray Bayly