2 Replies Latest reply on May 11, 2006 6:16 AM by DrEv1l

    giving arrays a dynamic name

    DrEv1l
      how would you give an array a dynamic name?

      for(f=0;f<6;f++){
      for(g=0;g<hexArray.length;g++){
      if(f==0){

      var kleurenIndexArray:Array = [] <---- this has to be a dynamic name like [kleurenIndexArray+f]
      kleurenIndexArray.push("0x"+g+"00000")
      }

      }
      }

      All the things i've tried haven't worked
        • 1. Re: giving arrays a dynamic name
          Craig Grummitt Level 3
          I'm not sure exactly what you're trying to do but to give any variable name based on a variable by doing something like:

          x=3;
          this["test"+x]="hello";

          this is the equivalent of writing:
          test3="hello";

          you would do the same for arrays such as:
          x=3;
          this["test"+x]=new Array();

          this is the equivalent of writing:
          test3=new Array();

          however, why not create an array rather than a variable with a dynamic name? my example above could be the following instead:
          eg
          test=new Array();
          test[3]=new Array();

          this would give you a multidimensional array.

          Does this answer your question?