3 Replies Latest reply on Mar 26, 2009 5:46 AM by Ned Murphy

    Reading data from a text file but can't use the data outside of the function.

    mauprice01 Level 1
      I am trying to load a variable from data in a text file.

      I can read the text file fine but the variable data seems only to be available with in the function that reads it.

      I need to use the variable data outside of the function.

      Does anyone have any suggestions to work around this issue?


      This is the actionscript code i'm using.

      var pathVars= new LoadVars();
      pathVars.onLoad=function(ok) {
      if(ok)
      {
      trace("Loading");
      path_var=pathVars.path;
      trace("This is within the function "+path_var);
      pathVar0="This is within the function... "+path_var;

      Yet the path_var is available here fine.
      }
      };
      pathVars.load("mypath.txt");


      This is where the path_var becomes undefined
      trace("This is outside the function... "+path_var);
      pathVar1="This is outside the function... "+path_var;



      This is a download link for the FLA zip file

      This is a demo of the script loading the text file