(Mx04) Generate mc's in rows

Hi

I can usually find/work out the answers from using the tutes but I’m stuck so I thought I’d ask here.

Following on from this post -

http://www.kirupa.com/forum/showthread.php?t=227686

I want the clips to be displayed in, for example, 2 rows of 3 clips, 6 in total.

By modding the AS to

total = 6;
for (i=0; i<total; i++) {
t = _root.createEmptyMovieClip(“xml”+i, i);
loadMovie(“imgBack.jpg”, “xml”+i);
}
t._x = (50*i) + 5
if (t._x > 400){
t._y = 300;
}
else{
t._y = 100;
}

I seem to have only the first clip displayed in the first row and the last clip in the last row.

What have I done wrong and how can I correct it?

I realise that the size of the jpg determines the point at which the second row is displayed so can I do it easily by determining that the third mc has been reached so start a new row?

cheers

Lee