create a new array with empty slots
ok, i was just about to create an array with empty slots (but ready to be filled someway later in the game for example, like: array[5][3]="hello") using AS...
as i haven't found a simple way to do it, here's the code so far:
code:
EmptyArray = new Array()
//
function createEmptyArray(lengthX, lengthY) {
EmptyArray = [];
EmptyArray.length = lengthY;
for (i=0; i<lengthY; i++) {
EmptyArray[i] = [];
EmptyArray[i].length = lengthX;
}
}
then simply call the function like that
code:
createEmptyArray(4, 2);
and it will give:
code:
EmptyArray = [[?,?,?,?],[?,?,?,?]]
// "?" here means nothing, empty
now...
what's the purpose of that thread!
1) my code is ugly and can be done in one/two line(s) of code. if so, any suggestion?
2) the code is perfect. if so, feel free to use it ;)