Thumbnails grid layout

hello.

i am trying to display a series of thumbnails (pulled from an xml file) using a grid layout. I am basically following the kirupa tutorial (xml photogallery w/ thumbnails) and i want to have a grid instead of a scroller…
something like:

1 5
2 6
3 7
4 8

at the moment i manage to put them in a single column, but i am having problems into finding a “formula” to make them sit in 2 columns.

following the tutorial i mentioned above, i am using a “counter” k and i basically trying to say :

if k>4 then re-initialise x and y values and carry on…

that’s where i am having problems…

anybody has done this before?

sorry if this has been posted here already

thanks in advance for help. :}

D

var rows = 4;
for (var i = 0; i<8; i++) {
	var mc = this["mc"+0];
	mc._x = Math.floor(i/rows);
	mc._y = i%rows;
}

scotty(-: