1 Reply Latest reply on Apr 17, 2006 7:54 PM by Newsgroup_User

    loading variables problem

    cd9
      Does anyone have a simple script that will load a variable from a text file. I have tried LoadVars and loadVariables? I'm sure I must be doing something wrong.

      I can display the variable value in a dynamic text box, but if I try to use the variable in an if statement, it doesn't work. If I trace the variable value, there is nothing.

      My text file, countphotos.txt, reads:
      &photocount=78

      An example of actionscript from this site that I tried is (I added the if statement):

      var my_lv:LoadVars = new LoadVars();
      my_lv.onLoad = function(success:Boolean) {
      if (success) {
      if (photocount==78){
      trace("photocount=" + photocount);
      trace(this.toString());
      }
      } else {
      trace("Error loading/parsing LoadVars.");
      }
      };
      my_lv.load("countphotos.txt");


      It traces nothing.
      If I remove the if statement, but leave the trace statements, I get:
      photocount=<p align="left"></p>
      photocount=78&onLoad=%5Btype%20Function%5D

      I also tried the if statement with quotes around 78.


      Thanks for any help.
      Howard
        • 1. Re: loading variables problem
          Level 7
          if (photocount=="78"){


          --
          Lon Hosford
          www.lonhosford.com
          May many happy bits flow your way!
          "cd9" <webforumsuser@macromedia.com> wrote in message
          news:e21917$7sq$1@forums.macromedia.com...
          Does anyone have a simple script that will load a variable from a text file.
          I
          have tried LoadVars and loadVariables? I'm sure I must be doing something
          wrong.

          I can display the variable value in a dynamic text box, but if I try to use
          the variable in an if statement, it doesn't work. If I trace the variable
          value, there is nothing.

          My text file, countphotos.txt, reads:
          &photocount=78

          An example of actionscript from this site that I tried is (I added the if
          statement):

          var my_lv:LoadVars = new LoadVars();
          my_lv.onLoad = function(success:Boolean) {
          if (success) {
          if (photocount==78){
          trace("photocount=" + photocount);
          trace(this.toString());
          }
          } else {
          trace("Error loading/parsing LoadVars.");
          }
          };
          my_lv.load("countphotos.txt");


          It traces nothing.
          If I remove the if statement, but leave the trace statements, I get:
          photocount=<p align="left"></p>
          photocount=78&onLoad=%5Btype%20Function%5D

          I also tried the if statement with quotes around 78.


          Thanks for any help.
          Howard