Advice on preloader for dynamic image gallery

Hello

The code below is my code for a image gallery. The code is implemented inside a mc, called gallery. When I attach this mc on stage, it will show thumbnails dynamicly loaded from the image arrays. To load the gallery mc, I use: _root.galleryMc.attachMovie(“gallery”,“galleryAttached”,1);

I want to create a preloader for this, and I’m not sure how to do it in the best way. I want to have another mc showing (the preloader) as long as all images hasn’t loaded. I wonder how I am going to hide this gallery as long as I need. Should I make an external mc for loading and then use *gallery._visible = true *when all images has loaded?

It would be smooth if I could have the gallery and it’s preloader in the same mc though…

//image arrays, contains the imagefolder and each image in that folder
imgArray = _root.getCurrentArray();
imgFolder = _root.getCurrentImgFolder();
size = imgArray.length - 1;

_root.setImageScrollSize(size);

//load all images
loadThumb();

//load thumbnail------------------------------------
function loadThumb() {
		for (i=0; i<size; i++) {
			 var thumb = this.createEmptyMovieClip("thumbnail"+i, i);
			 thumb.holder = thumb.createEmptyMovieClip("holder", 1);
				thumb._x = i*50;
				thumb.pic = imgFolder+imgArray*;
			    makeThumb(thumb.holder, thumb.pic, i);
				thumb.onRelease = function() {
					 trace("thumb "+imgArray*+" pressed");
				};
		}
}
function makeThumb(th, pic, depth) {
		th.loadMovie(pic);
		var temp = this.createEmptyMovieClip("temp", 999+depth);
		temp.onEnterFrame = function() {
			 if (th._width>0 && th._height>0 &&		 th.getBytesLoaded()==th.getBytesTotal()) {
					 //layer 'preloader'
	    		    	imgLoaded("add");
    		    		th._width = 50;
					 th._height = 50;
					 delete this.onEnterFrame;
				}
		};
}

regards, henxon