4 Replies Latest reply on Oct 7, 2006 3:50 PM by kglad

    LoadvariablesNum Does not work

    Thepoor13
      my text file is "Questions.txt" containt folowing text

      total="1"&question1="Ai la nguoi dau tien bay bao vu tru"
      &c11="Pham Tuan"
      &c21="Gargaky"
      &c31="Tao"
      &c41="Thang do"
      &ca1="2"

      in my movie, is use folowing command
      loadVariablesNum("Questions.txt",0);
      if (_root.total==undifined){
      trace("Can not load the Variables");
      }
      else
      {trace(total);
      }

      and the result is
      "Can not load the Variables"
      so The command "loadVariablesNum" does not work?
      "Questions.txt", "Test.fla" and "Test.swf" are put in the same folder "D:\Test\"
      could any one help me!
        • 1. Re: LoadvariablesNum Does not work
          kglad Adobe Community Professional & MVP
          you have several errors.

          first, you probably don't want quotes in your textfile.
          second, you probably do want to use the ampersand (&) before and after each variable/value pair.
          third, undefined should not be spelled undifined
          fourth, if you test for your variables to have loaded immediately after executing your loadVariablesNum() function, you're always going to find it has not loaded, yet.

          use a loop of some kind to repeatedly test if _root.total==undefined. if yes, continue to loop. if no, procede.

          or use targetMC.loadVariables() and use the onData() method
          or use the LoadVars() class and the onLoad() method.
          • 2. Re: LoadvariablesNum Does not work
            Thepoor13 Level 1
            i've checked all again, it's OK now
            but when i run following code

            loadVariablesNum("Some.txt", 0);
            var Question:Array = new Array();
            var Answer1:Array = new Array();
            var Answer2:Array = new Array();
            var Answer3:Array = new Array();
            var Answer4:Array = new Array();
            var CorectAnswer:Array = new Array();
            function loadDataintoArray() {
            var totalQuestion:Number = Number(total);
            for (i=1; i<=totalQuestion; i++) {
            Question = eval("Q"+i);
            Answer1
            = eval("A1" add i);
            Answer2 = eval("A2" add i);
            Answer3
            = eval("A3" add i);
            Answer4 = eval("A4" add i);
            CorectAnswer
            = eval("CA" add j);
            }
            }
            this.Confirm_btn.onRelease = function() {
            loadDataintoArray();
            };

            when i put on "Confirm" button, I have a following messege
            "A script in this movie is causing flash player run slowly. if it continuous to run, your computer may become unreponsive. Do you want to abort the script?"

            So how to repair the script?
            i run "Flash MX 2004 pro"
            i'm new to it, i need some help
            • 3. Re: LoadvariablesNum Does not work
              Thepoor13 Level 1
              oh,
              Question = eval("Q"+i);
              Answer1
              = eval("A1" add i);
              Answer2 = eval("A2" add i);
              Answer3
              = eval("A3" add i);
              Answer4 = eval("A4" add i);
              CorectAnswer
              = eval("CA" add j);
              they are missed index "i" when i write into web, but in my project they are corrected
              • 4. Re: LoadvariablesNum Does not work
                kglad Adobe Community Professional & MVP
                this forum interprets [ i ] as encoding for italic font. that's why your script is messed. to remedy, use the attach code option.

                to find your error use the trace() function. for example, in loadDataIntoArray() what is totalQuestion's value?