2 Replies Latest reply on Jul 12, 2007 1:31 PM by MyNameisNotTaken

    Updating dynamic text using a timer

    MyNameisNotTaken
      I have the below coding and I'm trying to update the text in my text box (my_txt) several times: at launch, at 12:01pm and after about a week. It updates at launch and after a week, but not at 12:01pm. I've marked the location where the error is occuring and coding isn't right. How do I update a dynamic text box using a timer with external text, coming from a website?

      Any help is appreciated



      var loadit:URLLoader = new URLLoader();
      loadit.addEventListener(Event.COMPLETE, completeHandler);
      loadit.load(new URLRequest(url));

      function completeHandler(event:Event):void {
      my_txt.text = event.currentTarget.data as String;
      my_sb.update();
      trace("Website Reference on Load");
      stop(); }

      var minuteTimer:Timer = new Timer(1000, 604800);
      minuteTimer.addEventListener(TimerEvent.TIMER, onTick);
      minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
      onTimerComplete);
      minuteTimer.start();

      function onTick(event:TimerEvent):void {
      trace("Tick " + event.target.currentCount);

      var time = new Date();
      var hours:uint = time.getHours();
      var minutes:uint = time.getMinutes();
      var seconds:uint = time.getSeconds();

      if(hours == 12, minutes == 01, seconds == 1) {
      my_txt.text = event.currentTarget.data as String; // <----- this is where I'm getting errors and what isn't working
      my_sb.update();
      trace("Alarm fired at 12:01:01 pm") } }

      function onTimerComplete(event:TimerEvent):void {
      my_txt.text = "You've left your PC on too long, restart for further updates";
      my_sb.update();
      trace("Timer fired, end at 604,800 seconds"); }