3 Replies Latest reply on Feb 28, 2007 4:49 AM by Pal_w_G

    days countdown from text file

    NuggetMan
      hi all. I'm using this script

      Code:

      this.createEmptyMovieClip("loader_mc", 0);
      loadVariables("assets/flash/splash/deadlines2.txt", loader_mc);
      // Variables declaration
      year;
      month;
      day;
      desc;
      // Check if variables text file are loaded
      function varLoaded() {
      if (loader_mc.y != undefined) {
      year = loader_mc.y;
      month = loader_mc.m;
      day = loader_mc.d;
      desc = loader_mc.desc;
      clearInterval(interval);
      }
      // Then call function to calculate days difference
      diffDays();
      }
      var interval = setInterval(varLoaded, 100);
      //
      function diffDays() {
      var end_date = new Date(year, month, day);
      var tmp_date = new Date();
      var now_date = new Date(tmp_date.getFullYear(), tmp_date.getMonth(), tmp_date.getDate());
      var difference = end_date.getTime()-now_date.getTime();
      var daysleft = difference/1000/60/60/24;
      desc2.autoSize = "left";
      desc2.htmlText = !daysleft ? "<b>> Today" : "<b>> " + daysleft+(daysleft>1 ? " Days</b>" : " Day</b>") + desc;
      desc2.setTextFormat(new TextFormat("Verdana", 9));
      }

      it acts pretty flaky, sometimes it works sometimes i get some weird results.

      if i put this:

      y=2007&m=2&d=23&desc= Deadline - Mar. 23, 2007


      into the txt file i get 23.9583333333333 Days. Which 23 isn't right even. plus i don't need any of those decimals. Any direction would be awesome.

      Thanks,
      Mike