8 Replies Latest reply on Feb 14, 2007 1:21 AM by ggshow

    LoadVars issue

    miquael Level 1
      Simply trying to pass a simple variable to a dynamic text field with Load Vars.

      I have "page1" as a variable in a page1.txt document with a long string of text. I use the following code to load and then pass that variable to a "page1" variable that is read into the dynamic text field. I have already confirmed that the variable is loading in a trace command, and have also confirmed that the dynamic text field is reading the "page1" variable. But when I run this and try to connect the two, I get "undefined" in the dynamic text field:

      ----------------------------------------------------------
      var my_lv:LoadVars = new LoadVars();
      my_lv.onLoad = function(success:Boolean) {
      if (success) {
      page();
      } else {
      trace("Error loading/parsing LoadVars.");
      }
      };
      my_lv.load("content/text/1/page1.txt");

      function page (){
      var page1 = my_lv.page1;
      trace (my_lv.page1);
      }
      ----------------------------------------------------------

      If i was to add:

      ----------------------------------------------------------
      var page1 = "test"
      ----------------------------------------------------------

      outside of the function, then "test" will show in the dynamic text field.

      What is the problem? What is the solution?