2 Replies Latest reply on Dec 3, 2007 11:50 AM by Tigomark

    Problems with Time

    Tigomark Level 1
      I have been working on a project and it is just been kicking my rear. Here it is in it's current rendition.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" width="100%" viewSourceURL="srcview/index.html" height="100%"
      initialize="getDaysUntil()" >
      <mx:Style source="source.css"/>
      <mx:Image source="@Embed('../images/title.jpg')" width="210" height="65" top="4" left="15"/>
      <mx:Image source="@Embed('../images/title1.jpg')" id="image1" horizontalAlign="right" verticalAlign="top" right="0" scaleContent="true" y="0"/>
      <mx:XML id="tempXML" source=" http://mysite.net/interface.php?username=admin&amp;password=pass&amp;customer=63&amp;actio n=showopen&amp;operation=defects&amp;format=xml&amp;critcal=both" />


      <mx:TileList
      dataProvider="{tempXML.defect.asset}"
      width="100%" backgroundColor="#000000" color="#ff0000" fontSize="27" borderColor="#000000" columnWidth="300" rowHeight="50" themeColor="#808080" fontWeight="bold" allowMultipleSelection="true" height="496" verticalCenter="28" horizontalCenter="-1"/>
      <mx:XMLListCollection id="defectXMLList" source="{tempXML.defect}" />

      <mx:Script>
      <![CDATA[


      private function getDaysUntil():void {
      // creates a new five-minute Timer
      var minuteTimer:Timer = new Timer(1000, 300);

      // designates listeners for the interval and completion events
      minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
      minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);

      // starts the timer ticking
      minuteTimer.start();

      }

      public function onTick(evt:TimerEvent):void
      {
      // displays the tick count so far
      // The target of this event is the Timer instance itself.
      trace("Seconds Left" + evt.target.lblTimeUntil.text);
      }

      public function onTimerComplete(evt:TimerEvent):void
      {
      trace("Time's Up!");
      var minuteTimer:Timer = evt.target as Timer;
      minuteTimer.reset();
      minuteTimer.start();
      }
      ]]>
      </mx:Script>

      <mx:HBox horizontalGap="4" x="400" y="500">

      </mx:HBox>
      <mx:Label id="lblTimeUntilRefresh" text="Time Until Refresh" color="red" fontSize="19" fontWeight="bold" x="387" y="500"/>
      <mx:Label id="lblTimeUntil" color="red" fontSize="22" fontWeight="bold" toolTip="Current Time Left" x="200" y="500" fontFamily="Arial"/>
      </mx:Application>

      The problem I am running into is everything in flex says it's fine but when I go to test the flash player completely hoses and comes up with the following error.

      ReferenceError: Error #1069: Property lblTimeUntil not found on flash.utils.Timer and there is no default value.
      at Red_Board/onTick()[C:\Documents and Settings\Mark\My Documents\Flex Builder 3\Red_Board\src\Red_Board.mxml:36]
      at flash.utils::Timer/_timerDispatch()
      at flash.utils::Timer/tick()
        • 1. Problems with Time
          m_hartnett Level 3
          The TimerEvent target is a flash.utils.Timer object and does not contain a reference to your lblTimeUntil label.

          Recode
          trace("Seconds Left" + evt.target.lblTimeUntil.text);
          to
          trace("Seconds Left" + lblTimeUntil.text);

          and you will not blow up anymore.

          This code will display the count up till refresh.
          public function onTick(evt:TimerEvent):void {
          var minuteTimer:Timer = evt.target as Timer;
          lblTimeUntil.text = minuteTimer.currentCount.toString();
          }
          • 2. Problems with Time
            Tigomark Level 1
            That fixed the blow up but the point of this is to make the time count down not up. Also is there a way to format this by minutes and seconds?