Assigning unique variables to movieclip instances?

This is a problem that has bugged me for a long time. I know there’s a solution, but I just can’t figure it out.

When one creates several instances of a movie clip on the main timeline, how can one assign separate variables to each of these instances and then invoke each of these values from the main timeline? I know how to do this by creating a separate movieclip and putting code on that movie’s timeline (using ‘this’), but I always feel this is sloppy because I’d like to keep my code all on one timeline.

Here’s some example code. It creates three instances of a movie clip, and assigns each one a variable called ‘contImage’ which contains the source of the loaded image. How can I get this variable traced when each of these images is clicked?

Thanks so much for anyone’s attention to this issue. Even though, as I said above, I have a work around, it has stuck in my craw for a while now.



var photos:Array = new Array('images/1.jpg', 'images/2.jpg','images/3.jpg');

for(var i:int = 0; i < photos.length; i++)
{
		var cont:MovieClip = new MovieClip;
		cont.x = i*100;
var contImage:String = new String;
		cont.contImage = photos*;
		addChild(cont);
		
		var loader:Loader = new Loader();
		loader.load(new URLRequest(photos*));
		cont.addChild(loader);
		
		cont.addEventListener(MouseEvent.CLICK, showImageSource);
		function showImageSource(e:MouseEvent)
		{
			// what code would I put here to trace the value of the variable 'contImage' (which is the source of the image)?
		}
		
}