Multidimensional array (Flash MX)

Hi guys,
I have created a 2 dimensional array call table and want to assign each and every elements in that array to 0. The codes below shows how I have done it:

var table = new Array();

table = [ [0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0], [0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0] ];

Just like to find out if there is a simpler way to do it. I’ve tried doing it with a ‘for’ loop but I always get ‘undefined’ values.

So, anyone has got any idea on how to do it?

this one works:


// this one will make an 20x20 array.... 
// you can change this if you want...
myArray = new Array();
for(i=0;i<20;i++){
    myArray* = new Array();
    for(ii=0;ii<20;ii++){
        myArray*[ii] = 0;
    }
}

you need to declare the Array twice with an 2 dem. array (only with using a loop)

if i starts at 0 and goes until <= 20 wouldnt that create a 21X21 array because i know it would in c++ and i dont know much about actionscript yet (just trying to find some simarlities here)

I think you are right, jonnooe… :wink:

oops :stuck_out_tongue: make that < instead of <= hehe stupid me

LOL…Thanks for your help, guys. Really appreciate it.