Array of images: Can't get the alignment right....!

Hi,
I’m making an array of clickable images, based on kirupas gallery tutorial.
I want images in rows and columns. To show images in rows and columns i need to change the ._y and ._x coordinate everytime the image hits the end of the screen…
Here is the code:


tlistener.onLoadInit = function(target_mc) {
		target_mc._x = (target_mc._width+1)*k;
		
		**if (target_mc._x > 400){
			target_mc._y = target_mc._y + 70;
			target_mc._x = 0;
		}**
		
		trace("target_mc._x: "+target_mc._x);
		
		target_mc.pictureValue = k;
		target_mc.onRelease = function() {
			p = this.pictureValue-1;
			//nextImage();
		};
		
		target_mc.onRollOver = function() {
			this._alpha = 50;
//			thumbNailScroller(); //add sound here
		};
		target_mc.onRollOut = function() {
			this._alpha = 100;
		};
	};

The output from this function is as follows:

traget_mc: 0
traget_mc: 0
traget_mc: 0
traget_mc: 0
traget_mc: 0
traget_mc: 0
traget_mc: 0
traget_mc: 0
traget_mc: 303
traget_mc: 202
traget_mc: 101
traget_mc: 0

When the image’s x-coordinate is > than 400 the image should shift down (using ._y + 70), and the x-coordinate should be reset to zero to place the images right underneath another.
BUT, when i set ._x to zero it stays at zero throughout the rest of the loop…!!! (function calls)

Please help me…i’m baffled!!

Cheers,

Dave