# Help.. how to ensure that images is loaded according to the order in xml

**URL:** <https://forum.kirupa.com/t/help-how-to-ensure-that-images-is-loaded-according-to-the-order-in-xml/287628>\
**Category:** flash\
**Created:** [May 4, 2009, 2:58pm UTC](https://forum.kirupa.com/t/help-how-to-ensure-that-images-is-loaded-according-to-the-order-in-xml/287628 "2009-05-04T14:58:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hillary](https://avatars.discourse-cdn.com/v4/letter/h/3bc359/32.png) [@hillary](https://forum.kirupa.com/u/hillary)\
**Post date:** [May 4, 2009, 2:58pm UTC](https://forum.kirupa.com/t/help-how-to-ensure-that-images-is-loaded-according-to-the-order-in-xml/287628/1 "2009-05-04T14:58:01Z")

</div>

Hi,

I had created a flash which load several images and display it using loadMovieClip(). I need the images to load in a specific order according to the information retrieve from a xml file. However, my scripts only works well if it was tested in my local computer. In online environment, the images seems to load in a random sequence. Do anyone have any idea to fix it so that the images loads according to the xml order?

Below is my scripts:

var myShowXML = new XML();  
myShowXML.ignoreWhite = true;  
myShowXML.load(“galleryxml.xml”);

myShowXML.onLoad = function() {

```
_root.myWidth = myShowXML.firstChild.attributes.width;
_root.myHeight = myShowXML.firstChild.attributes.height;
_root.mySpeed = myShowXML.firstChild.attributes.speed;

_root.myImages = myShowXML.firstChild.childNodes;
_root.myImagesNo = myImages.length;

loadAvatar();
createContainer();
callImages();

```

};

function loadAvatar() {  
avatar.loadMovie(\_root.myAvatar);  
}

function createContainer() {  
\_root.createEmptyMovieClip(“myContainer\_mc”,\_root. getDepth()-1);

```
myContainer_mc.lineTo(_root.myWidth,0);
myContainer_mc.lineTo(_root.myWidth,_root.myHeight );
myContainer_mc.lineTo(0,_root.myHeight);
myContainer_mc.lineTo(0,0);

myContainer_mc._x = (Stage.width-myContainer_mc._width)/2;
myContainer_mc._y = (Stage.height-myContainer_mc._height)/2;

```

}

function callImages() {

```
_root.myMCL = new MovieClipLoader();
_root.myPreloader = new Object();
_root.myMCL.addListener(_root.myPreloader);

_root.myClips_array = [];

_root.myPreloader.onLoadStart = function(target) {

	_root.createTextField("filename_txt",_root.getNext HighestDepth(),0,0,100,20);
	_root.filename_txt._x = 70;
	_root.filename_txt._y = 305;
	_root.filename_txt.autoSize = "left";

};

_root.myPreloader.onLoadProgress = function(target) {

	_root.filename_txt.text = "Loading.. "+_root.myClips_array.length+"/"+_root.myImagesNo+" Completed";

};

_root.myPreloader.onLoadComplete = function(target) {

	_root.myClips_array.push(target);
	trace(target._name);
	target._alpha = 0;

	if (_root.myClips_array.length == _root.myImagesNo) {

		moveSlide();
		if (_root.myImagesNo&gt;1) {
			myShowInt = setInterval(moveSlide, (_root.mySpeed*1000)+1000);
		}
	}

};

for (i=0; i&lt;_root.myImagesNo; i++) {
	temp_url = _root.myImages*.attributes.file_preview;
	temp_mc = myContainer_mc.createEmptyMovieClip(i, myContainer_mc.getNextHighestDepth());
	_root.myMCL.loadClip(temp_url,temp_mc);
}

```

}

function moveSlide() {  
current\_mc = \_root.myClips\_array[\_root.target\_mc];  
new Tween(current\_mc, “\_alpha”, Strong.easeOut, 100, 0, 1, true);

```
_root.target_mc++;

if (_root.target_mc&gt;=_root.myImagesNo) {
	_root.target_mc = 0;
}

_root.filename_txt.text = _root.myImages[_root.target_mc].attributes.file_name;
next_mc = _root.myClips_array[_root.target_mc];
new Tween(next_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);

```

}
