2 Replies Latest reply on Jul 19, 2006 3:27 PM by CogDev

    2 dimensional arrays...

    DZ-015 Level 1
      The title pretty much says it all...

      I just want to know how to create and how to reference 2 (or more) dimensional arrays.

        • 1. Re: 2 dimensional arrays...
          kglad Adobe Community Professional & MVP

          • 2. Re: 2 dimensional arrays...
            It's pretty straightforward, all you have to do is assign a variable to an array that contains arrays.

            To reference them, just have the first index, followed by the second index. Here's an example:

            // This will output the Multiplication table from 0 to 9 using a 2 dimensional array
            var numberArray = [[null],[null],[null],[null],[null],[null],[null],[null],[null],[null]];

            for(var i=0; i < 10; i++){
            for(var j=0; j < 10; j++){
            numberArray [j] = j*i;

            I hope that helps. I wish I knew exactly why you have to initialize the array to the length you want it to be, but if you don't you'll "undefined". There are probably better ways of doing this.