How to assign a value to Multidimentional arrays in AS3 Actionscript 3
This has to be one of those times where I wanted to smash my monitor over something so painfully simply. Assigning values to arrays should be as easy as saying _somearray[x]=100.
Great, that works. But what about a multidimensional arrays? What do you know _somearray[x][y]=100 does NOT work. Why in the world couldn’t be that simple. I dont know, but here’s how it’s done.
First you want to do your normal public var _somearray:Array = new Array();
Next, somewhere in your code, you need to do this, _somearray[0] = new Array(); Basically you are assigning an array to an array.
You can include this in a loop like so.
for(var i:int=0;i<5;i++){
for(var y=0;y<256;y++){
for(var x=0;x<256;x++){
WaveMap[i][y*256+x]=0;
}
}
}
Now any time you want to assign your array, _somearray[0][0] = whatever, will do the trick.
You can also do _somearray[0][0] = new Array() and you’ll be able assign values like, _somearray[0][0][0] = somevalue.

