5 Replies Latest reply on Sep 7, 2006 10:13 PM by kglad

    LoadVars() Problem?

    TheInmate
      Hello,

      I've created four clocks in Flash that load minutes and hour and day information from a php file. When Flash first loads, it works just fine. Whenever it comes around to a new hour for some reason my code is not accessing the new hour, though it still does for the minute and, I presume, the day. If I refresh the browser then everything is fine again. I.e. Let's say it is 3:59 when the minute changes to 00 the clock shows 3:00 instead of 4:00 and it will continue to use 3 as the hour (still advancing the minutes) until I refresh the browser though it is still changing the minute from the same php file where the hour information is accessed. I've got the flash file set 12 fps at 720 frames. I've tried less frames and it still does the same thing. The clocks are in movieClips which are running in 2 frames. Here's, what I hope, is the pertinent code:

      The PHP file:

      <?php
      //Tokyo
      putenv('TZ=Japan');
      $tDay = strftime('%u');
      $tHours = strftime('%H');
      $tMins = strftime('%M');
      //San Diego
      putenv('TZ=PST8PDT');
      $sDay = strftime('%u');
      $sMins = strftime('%M');
      $sHours = strftime('%H');
      //New York
      putenv('TZ=EST5EDT');
      $nDay = strftime('%u');
      $nHours = strftime('%H');
      $nMins = strftime('%M');
      //London
      putenv('TZ=Europe/London');
      $lDay = strftime('%u');
      $lHours = strftime('%H');
      $lMins = strftime('%M');
      echo "tDay=$tDay&tHours=$tHours&tMins=$tMins&sDay=$sDay&sHours=$sHours&sMins=$sMins&nDay=$nDay &nHours=$nHours&nMins=$nMins&lDay=$lDay&lHours=$lHours&lMins=$lMins";
      ?>

      The Actionscript LoadVars code on the main timeline (_root):

      var myTimes:LoadVars = new LoadVars();
      myTimes.load(' http://www.helpyoutrade.com/flash/clockTimezones.php');

      myTimes.onLoad = function( success ){
      if(success){
      trace("variables loaded");

      // MY VARIABLES
      // FROM PHP PAGE

      //Tokyo Information
      _global.tDay = myTimes.tDay;
      _global.tHours = myTimes.tHours;
      _global.tMins = myTimes.tMins;

      //San Diego
      _global.sDay = myTimes.sDay;
      _global.sHours = myTimes.sHours;
      _global.sMins = myTimes.sMins;

      //New York
      _global.nDay = myTimes.nDay;
      _global.nHours = myTimes.nHours;
      _global.nMins = myTimes.nMins;

      //London
      _global.lDay = myTimes.lDay;
      _global.lHours = myTimes.lHours;
      _global.lMins = myTimes.lMins;

      } else {
      trace("Error loading page");
      } // if success else end
      } // function success end

      And the clock code (I have four clocks) showing four different timezones(in a movieClip):

      MyDate = new Date();
      // I use this only to access seconds off the users computer
      // all other information comes from the php file

      var sSecs = MyDate.getSeconds();

      // code for clock
      seconds = sSecs;
      minutes = sMins;
      hours = sHours;


      hours = hours + (minutes/60);

      seconds = seconds*6; // calculating seconds
      minutes = minutes*6; // calculating minutes
      hours = hours*30; // calculating hours

      sec._rotation=seconds; // giving rotation property for the second hand
      min._rotation=minutes; // giving rotation property for minute hand
      hour._rotation=hours; // giving rotation property for the hour hand

      I'm baffled. I'm a beginner at actionscript, so any help would really be appreciated.

      Regards,

      Glen
        • 1. Re: LoadVars() Problem?
          kglad Adobe Community Professional & MVP
          append a something to your php file name so it's not re-used from your browser's cache:

          • 2. LoadVars() Problem?
            TheInmate Level 1
            I really thought that was going to work (praised the merits of the simplicity of the answer to my wife), but it didn't. Any other ideas? Do I need to add anything to the php file? $_GET['randNum']?

            Thanks.

            Glen
            • 3. Re: LoadVars() Problem?
              kglad Adobe Community Professional & MVP
              1. your onLoad handler should be defined before your load() statement.
              2. what are you doing with your variables: seconds, minutes and hours?
              3. how often are you updating your 4 clocks?
              4. do you call your php script more than once?
              • 4. Re: LoadVars() Problem?
                TheInmate Level 1
                Hello,

                Thanks again for getting back to me. My responses to your questions/statements follow:

                1. your onLoad handler should be defined before your load() statement.

                Sorry for my ignorance here, but not sure what you mean.

                2. what are you doing with your variables: seconds, minutes and hours?

                I'm using them to position the hands of the clocks via the rotation property.

                3. how often are you updating your 4 clocks?

                Started at every minute. I'm updating them now about every 30 seconds.

                4. do you call your php script more than once?

                Every 30 - 60 seconds - unless I don't know what I'm doing (to some degree this is true). The flash file is looping and I assume everytime it comes around to frame one, where the actionscript is that you see below, that it is reloading the php file. I assume it has to be because my minutes are working fine and I've watched it using trace(). Everything changes except for the hour.

                Thanks.

                • 5. Re: LoadVars() Problem?
                  kglad Adobe Community Professional & MVP
                  see below: