1 Reply Latest reply on Oct 8, 2006 11:00 AM by kglad

    Loading text into multiple t-fields

    Ares94
      I have a swf where there are 5 text fields on the stage.
      I need to load some text into each of those text fields.
      Every text field has it's own external .txt file that needs to be loaded into it.

      So far I've been using the LoadVars class but each swf had only one text filed.
      I could write the LoadVars object so that it's non-specific, I could give the same name to all the text fields because there was only ONE text field per swf. They couldn't mix as the next swf that was loaded kicked out the one that was already there.

      But now, with 5 text fields in ONE swf, obviously I can't name them all the same.

      What is the best solution?
      Should I define a NEW LoadVars object for each of those text fields?

      Or could I somehow use a function with 2 parameters?
      So that the .onLoad part is inside that function and has a parameter for the text field instance name and a parameter for the variable that is asigned to the text in the external .txt file.
      Can I then simply call that function 5 times and each time I call it give it a new pair of parameters?

      Something like:

      var lv:LoadVars = new LoadVars();

      function loadingText ( instName:String, varName:String): Void {
      lv.onLoad = function {
      _level5. instName.text = lv. varName;
      }
      }

      loadingText ("field1", "var1");
      loadingText ("field2", "var2");
      loadingText ("field3", "var3");
      ....


      Thanks!