AS3 Multidimensional Array
Hi.
I'm new to AS3. I would like to know how can I create a multidimensional array (eg. 8x8) using for or while. The values in it must be only: red, blue, green, yellow and black.
Thanks.
Hi.
I'm new to AS3. I would like to know how can I create a multidimensional array (eg. 8x8) using for or while. The values in it must be only: red, blue, green, yellow and black.
Thanks.
If you want to pick the colors randomly, place them in an array and randomly pick one of them by using the Math methods...
var colorArray:Array = new Array("red", "blue", etc...)
for(var i:int=0; i<8; i++){
mArray = new Array();
for(var k:int=0; k<8; k++){
mArray.push(colorArray[Math.floor(Math.random()*colorArray.length)]);
}
}
Already have an account? Login
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.