5 Replies Latest reply on Mar 7, 2007 3:39 AM by phil ashby

    Show Real Time

    Jafang
      Hi guys,
      I am trying to get the server time in real time and I can't get it to count the seconds in realtime,
      I am able to get the time from CFM to Flash, but if I loop the frame in order to get the real time like the seconds, my page takes forever to load. Can someone please tell me what I am doing wrong?
      What is the best way to get the servertime and make Flash to show the counting seconds in realtime. Like This one but geting the time from CFM.


      Here are my codes:
      In CFM:
      <cfset todayDate = Now()>
      <cfoutput>&servertime=#TimeFormat(todayDate, "h:mm:ss tt")#</cfoutput>

      In Flash frame one (1):
      loadVariablesNum("showTime.cfm", 0);
      this.onEnterFrame = function() {
      servertime = eval("servertime");
      MyTime = unescape("Server Time is: "+servertime);
      };

      In Frame tree(3):
      gotoAndPlay(1);

      Thanks in advance.
        • 1. Re: Show Real Time
          phil ashby Level 1
          Rather than do multiple calls, why not get the servertime once and then compare it to localtime to find the difference between the two. Then just display the local time +- the difference...?
          • 2. Re: Show Real Time
            Jafang Level 1
            Thanks for reply , I'll tried that, but run into problems with daylight saving time.
            The Date object handles daylight saving time differently depending on the operating system and the Flash Player version. That is according to Adobe.
            • 3. Show Real Time
              phil ashby Level 1
              ok...depending on the absolute accuracy you need, how about this...

              why not get the date/time say every 60 seconds using setInterval as your timer

              something like this

              // call getdate to get the initial datetime
              getdate()

              function getdate()
              {
              // clear any interval timers
              clearInterval(mynewdate)

              // get and display your date
              loadVariablesNum("showTime.cfm", 0);
              servertime = eval("servertime");
              MyTime = unescape("Server Time is: "+servertime);

              // recall this function in 60 seconds
              mynewdate = setInterval(getdate,60000)
              }

              You don't need your loop then and can then modify the date display to show 10:45 without the seconds.
              If you want it with seconds then reduce the 60000 to 1000, but I don't think Flash will be able to cope, as if the loading takes longer than a second it maynever get round to displaying the text?!

              hope this helps
              Phil


              • 4. Re: Show Real Time
                Jafang Level 1
                Thanks Phil,
                Many, many thanks,
                That would solve my problem,

                You are the best.
                • 5. Re: Show Real Time
                  phil ashby Level 1
                  glad to be of help