Arrays within arrays

It shouldn’t be this complicated, but I’m stuck! I’m working on creating a music sequencer in Flash like you see in Fruity Loops or any audio software…

The first thing I’m trying to do is make a grid, using arrays, and each cell in the grid is a new instance of GridSquare (which is just a square with a black outline). I need 82 rows for each piano key in the sequencer.


var secondRowY:Number = 108;
var numberOfCells:int = 24;
var rowOne:Array = [];
var rowTwo:Array = [];

createGrid();

function createGrid():void
{
	for (var a:int = 0; a <= numberOfCells; a++)
	{
		var grid_cell:GridSquare = new GridSquare();
		rowOne.push(grid_cell);
		addChild(rowOne[a]);
	}
	for (var b:int = 0; b <= numberOfCells; b++)
	{
		var grid_cell2:GridSquare = new GridSquare();
		rowTwo.push(grid_cell2);
		addChild(rowTwo**);
	}
	for (var c:int = 0; c <= numberOfCells; c++)
	{
		var grid_cell3:GridSquare = new GridSquare();
		rowThree.push(grid_cell3);
		addChild(rowThree[c]);
	}
	for (var d:int = 0; d <= numberOfCells; d++)
	{
		var grid_cell4:GridSquare = new GridSquare();
		rowFour.push(grid_cell4);
		addChild(rowFour[d]);
	}
	for (var e:int = 0; e <= numberOfCells; e++)
	{
		var grid_cell5:GridSquare = new GridSquare();
		rowFive.push(grid_cell5);
		addChild(rowFive[e]);
	}
	for (var f:int = 0; f <= numberOfCells; f++)
	{
		var grid_cell6:GridSquare = new GridSquare();
		rowSix.push(grid_cell6);
		addChild(rowSix[f]);
	}
	for (var g:int = 0; g <= numberOfCells; g++)
	{
		var grid_cell7:GridSquare = new GridSquare();
		rowSeven.push(grid_cell7);
		addChild(rowSeven[7]);
	}
}

And the rest of the code is just setting the x and y values of the grid cells.

Instead of having that many for loops (and there are supposed to be 82 of them!), I’m looking for any way to simplify this. Simplifying is the hardest thing to do for me…

I’m trying to imagine a nested array that looks like this:

var mainGrid:Array = [rowOne, rowTwo, rowThree]

I’ve just about given up hope!