Arrays

I want to create a 2 dimensional array that is 55x40 and holds integers(initialized to zero); what is the code?

I tried using

for(i = 0; i < 55; i++)
{
for(j = 0; j < 40; j++)
{
array*[j] = 0;
}
}

but when I trace the values out it says undefined…

thanks

arrays are 1 dimensional as far as I know. You would have to store arrays inside arrays to get a 2d type I think. There might be a 2d way, I just dont know it.

myarray = new Array(55)
for( i=0; i<55; i++ ) {
myarray* = new Array(40)
for( j=0; j<40; j++ ) {
myarray*[j] = 0
trace ( myarray*[j] )
}
}

Hi,

try this instead

myArray = new Array();
for(i=0;i<55;i++){
for(j=0;j<40;j++){
myArray*[j] = 0;
}
}

Liz

Thanks ahmed…that works.

I thought you did’nt need to allocate vars in Flash.

its not the allocating, he put arrays inside arrays. he has one array filled with 55 more arrays each 40 in length. This basically creates a 2d array.