Creating a grid of hexes using for loops

I’m trying to create a grid of hexagons by using nested for loops. I picked up this code trawling the forums but this creates a diamond shaped pattern of hexes rather than neat rows that interlock together. I want to create one row in the first place, increment the x and y placing coords so as the next row is offset as appropriate to lock it into place under row above. Can’t get my head round it. It’s been a long day-too much wine-Flash newbie…You get the picture. Can anyone sort this out?

This is the code I’m using, which is clearly not doing the trick.

spacing = 35;
spacing2 = 35;
for (x = 0; x < 10; x++){
for (y = 0; y < 10; y++){
tile = this.attachMovie(“mytile”, “mytile” + depth, depth++);//attaches the tile
tile._x = spacing * (x + y);
tile._y = spacing2* (x - y);
tile.x = x;
tile.y = y;
tile.onRelease = function(){
trace("x: “+this.x+”, y: "+this.y);


Any help would be much appreciated.

(fla attached if you want to take a look)