# How to add a preloader to a Thumbnails gallery (XML)

**URL:** <https://forum.kirupa.com/t/how-to-add-a-preloader-to-a-thumbnails-gallery-xml/286259>\
**Category:** Uncategorized\
**Created:** [April 13, 2009, 1:37am UTC](https://forum.kirupa.com/t/how-to-add-a-preloader-to-a-thumbnails-gallery-xml/286259 "2009-04-13T01:37:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![deathz](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@deathz](https://forum.kirupa.com/u/deathz)\
**Post date:** [April 13, 2009, 1:37am UTC](https://forum.kirupa.com/t/how-to-add-a-preloader-to-a-thumbnails-gallery-xml/286259/1 "2009-04-13T01:37:19Z")

</div>

Hi guys,

I’ve been trying to add a preloader to my thumbnails, but it has been quite difficult (really considering the idea of buying an AS3 book).

Well, this is what I have  
First the code to call the Thumbs from the XML file.

> function callThumbs():void {  
> for (var i:Number = 0; i \< my\_total; i++) {

```
	var thumb_url = my_videos*.@THUMB;

	var thumb_loader = new Loader();
	thumb_loader.load(new URLRequest(thumb_url));
	thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
	thumb_loader.name = i;

	thumb_loader.x = (my_thumb_width+10)*x_counter;
	thumb_loader.y = (my_thumb_height+10)*y_counter;

	if (x_counter+1 &lt; columns) {
		x_counter++;
	} else {
		x_counter = 0;
		y_counter++;
	}

}

```

}

After this when the Thumb is loaded I have the thumbLoaded function to display it as follows:

> 

function thumbLoaded(e:Event):void {  
var my\_thumb:Loader = Loader(e.target.loader);  
container\_mc.addChild(my\_thumb);  
my\_tweens[Number(my\_thumb.name)]=new Tween(my\_thumb, “alpha”, Strong.easeIn, 0,1,0.5, true);  
my\_thumb.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded);  
}

What I really need to know is how to add a MovieClip to container\_mc and when the Thumb is loaded, remove this MovieClip from it?
