View Full Version : Arrays
rysolag
September 4th, 2003, 06:32 PM
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[i][j] = 0;
}
}
but when I trace the values out it says undefined...
thanks
grandsp5
September 4th, 2003, 06:41 PM
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.
ahmed
September 4th, 2003, 06:41 PM
myarray = new Array(55)
for( i=0; i<55; i++ ) {
myarray[i] = new Array(40)
for( j=0; j<40; j++ ) {
myarray[i][j] = 0
trace ( myarray[i][j] )
}
}
lac
September 4th, 2003, 06:42 PM
Hi,
try this instead
myArray = new Array();
for(i=0;i<55;i++){
for(j=0;j<40;j++){
myArray[i][j] = 0;
}
}
Liz
rysolag
September 4th, 2003, 06:49 PM
Thanks ahmed...that works.
I thought you did'nt need to allocate vars in Flash.
grandsp5
September 4th, 2003, 06:52 PM
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.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.