# Preloading external images via loadMovie function

**URL:** <https://forum.kirupa.com/t/preloading-external-images-via-loadmovie-function/299163>\
**Category:** flash\
**Created:** [October 30, 2009, 7:31pm UTC](https://forum.kirupa.com/t/preloading-external-images-via-loadmovie-function/299163 "2009-10-30T19:31:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![M12](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@M12](https://forum.kirupa.com/u/M12)\
**Post date:** [October 30, 2009, 7:31pm UTC](https://forum.kirupa.com/t/preloading-external-images-via-loadmovie-function/299163/1 "2009-10-30T19:31:03Z")

</div>

Hey,

I have a flash website, which has 4 menu options, each of which when you click fetches a different XML file in which the child nodes indicate the content, or description of an item, and fetch a external image to represent it on stage. Each menu option when clicked gets a new XML file, replacing the old one in the xml variable. Once the XML is loaded (xml.onLoad()) it sends it to a function (loadItems) to place each item on stage. Obviously, when uploaded onto the Internet, when a XML loads, the images are still loading, thus the Tween effect of them appearing on stage can’t be seen.

I need to find a way of how to create a preloader, that would show the status of ALL the images download progress, and once complete, starts the Tween effect of them appearing on stage.

**loadItems function (places the external images from the XML file on stage):**

```auto

var xml:XML = new XML();
xml.ignoreWhite = true;

function loadItems()
{
	var nodes = this.firstChild.childNodes;
	numOfItems = nodes.length;
	for(var i=0;i<numOfItems;i++)
	{
		var t = home.attachMovie("item","item"+i,i);
		t.icon.inner.loadMovie(nodes*.attributes.image);
		t._x = i*50;
		t._y = 395;
		t._alpha = 0;
		t._xscale = t._yscale = 0;
	}
		
	for (i=0; i<numOfItems; i++)
	{

		var tw:Tween = new Tween(home["item"+i], "_alpha", Strong.easeOut, home["item"+i]._alpha, 80, 1, true);
		var tw:Tween = new Tween(home["item"+i], "_xscale", Strong.easeOut, home["item"+i]._xscale, 50, 1, true);
		var tw:Tween = new Tween(home["item"+i], "_yscale", Strong.easeOut, home["item"+i]._yscale, 50, 1, true);

	}
}

```

**Each menu button, when released:**

```auto

	xml.load("xmlfile.xml");
	xml.onLoad = loadItems;

```

\*\*Sample a node in the XML file:  
\*\*

```auto

<icons>

<icon image="1.png" content="Description of item." />

</icons>

```

Any ideas or suggestions?

Thanks in advance!  
M12
