Make a grid menu using an array

Advertisement
Hi,
I was wondering if there is a way to make a menu of buttons from an array arrange themselves in a 3x3 grid.
I have used code i have gotten from this forum to place them next to each other onto the stage (which was quit awesome) and i have found code to place them in a rotating cell from an array but is it possible to do it as a grid?
Any help would be great
Advertisement

Replay

use Math.floor and the modulo operator to construct grids:
var xSpace:int = 100;
var ySpace:int=100;
var rowNum:int=3;
var colNum:int=3;
for(var i:int=0;i<yourarray.length;i++){
yourarray[i].x=xSpace*i%rowNum;
yourarray[i].y=ySpace*Math.floor(i/colNum);