How can I send an image to the end of the row?

Hi, everybody!

I’m working on an image gallery, I got inspiration from sen’s tutorials and this gallery works, but not like I would like it to work.

This gallery loads images from an xml file and place them into some containers on stage.This gallery gives the idea of perspective and space.
All the images are placed in 5 rows (8 images per row, a total of 40).
When you rollOver an image it comes to the front.
What I can’t manage yet is how to send the image to the end of the row, I mean, when you rollOver the third image I want the previous two to go to the end of the row.

I hope I made myself clear.
All comments, suggestions, and above all help are very welcome!
Thanks in advanced.

I think this is the function that I need to correct:


displayStar = function (cameraView, focalLength) {
	var x = this.x-cameraView.x;
	var y = -100;
	var z = this.z-cameraView.z;
	if (z<0) {
		this.z += (5000-1000);
		this.x = this.x+(i*40);
		this.y = -500;
		x = this.x-cameraView.x;
		y = this.y-cameraView.y;
		z = this.z-cameraView.z;
	}
	var scaleRatio = focalLength/(focalLength+z);
	this._x = x*scaleRatio;
	this._y = y*scaleRatio;
	this._xscale = this._yscale=100*scaleRatio;
	this.swapDepths(1000-z);
};

dec27 :ko: