1 Reply Latest reply on May 20, 2006 4:36 AM by blemmo

    loading a movie from a php variable

    Kevin0612
      I have a web site that has publicity on it.

      What I need to do in flash is to load a php file that will send me a link that his chosen randomly and then in flash I have something like loadmovie(the link from php)

      Also at the end of each movie it need to reload that php file and load another publicity.

      What I have right now in my main flash is the fallowing

      loadVars = new loadVars();
      loadVars.load("pub.php");
      loadVars.onLoad = function(success) {
      if (success) {
      pub.loadMovie(this.var2);
      } else
      {
      pub.loadMovie("pub1.swf");
      }
      };
      break;


      and at the end of each pub I have this :

      loadVars = new loadVars();
      loadVars.load("pub.php");
      loadVars.onLoad = function(success) {
      if (success) {
      _root.pub.loadMovie(this.var2);
      } else
      {
      _root.pub.loadMovie("pub1.swf");
      }
      };
      break;

      Right now the first movie load but when the first pub end it just loop at the beginning and never load anything else
      the only time something work was when I hard coded the link by using

      this.loadMovie(my path here);
      break;
        • 1. loading a movie from a php variable
          blemmo Level 1
          Try placing a stop(), command on the last frame of the loaded movies, to avoid replay while loading. Also, trace the loaded variable to see if it changes:
          --
          stop();
          loadVars = new LoadVars();
          loadVars.load("pub.php");
          loadVars.onLoad = function(success) {
          if (success) {
          trace(this.var2);
          _root.pub.loadMovie(this.var2);
          } else
          {
          _root.pub.loadMovie("pub1.swf");
          }
          };
          --
          If var2 is always the same, then Flash uses the cached php. To force a reload instead of using the cached version, add a timestamp to the load command:
          loadVars.load("pub.php?foo="+getTimer());
          This way it's always a new URL, and Flash will load it again from the server.

          The 'break' statements are useless here, they just do something in switch, while or for statements.

          Oh, and make sure to use the correct case:
          loadVars = new LoadVars();
          In the newer Flash versions, AS is strictly case sensitive, and the class is called LoadVars.

          hth,
          blemmo