Attatching AS to movieclips created using duplicateMovieClip

Hullo.

I’m trying to create a photogallery. I read both of the tutorials on the site, but couldn’t find the answer to my problem. First, I will outline my methodology.

There is a directory called images, and therein are stored (surprise surprise) the images for the gallery. There is also a textfile that contains the number of images in the gallery.

Flash runs a loop that uses duplicateMovieClip to create instances of each image and set them up into rows and columns.

That’s as far as I’ve gotten.

I want to be able to click these new movie clips, and have the image that was clicked appear in full size at the top of the screen. Basically, I just need to know how to assign actions to these newly created clips. Is it possible to do this when they are being created? Here’s my code, thus far. I’m sorry if it’s a backwards or stupid way of doing things, but I was trying to work from scratch, and my knowledge of actionscript is limited.

var beam:LoadVars = new LoadVars();

beam.load("/images/imagecount.txt");
    
row = 1;
col = 1;

beam.onLoad = function(){
    
     count = beam.count;


     for(i=1; i<6; i++) {
         picpath = &quot;/images/&quot;+i+&quot;.jpg&quot;;
        picholder = &quot;pic&quot;+i;
        holder.duplicateMovieClip(picholder, i, {_x:(col*110), _y:(row*120)});
        loadMovie(picpath, picholder);
        col = col + 1;
        
        if (col > 3) {
            col = 1;
            row = row + 1;
        }
    }
}