5 Replies Latest reply on Apr 16, 2006 12:56 PM by kglad

    Declaring variables dynamically

    maguskrool Level 1

      I have a project that requires loads of variables with similar names but distintc values. I was wondering if there was a way to declare them automatically, providing only a string with the variable's name and a number that indicates the amount of variables (and would be used to index them). I would like something like this:

      var nTotalVars:Number = 10;
      var sVarName:String = "MyVar";
      for (i = 1; i < nTotalVars ; i++) {
      var [sVarName+i]:Number = ...;

      Is there a way to do this? Thank you in advance.