# Movie clip preloader with xml

**URL:** <https://forum.kirupa.com/t/movie-clip-preloader-with-xml/188356>\
**Category:** Uncategorized\
**Created:** [May 6, 2006, 10:13pm UTC](https://forum.kirupa.com/t/movie-clip-preloader-with-xml/188356 "2006-05-06T22:13:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vicente](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@Vicente](https://forum.kirupa.com/u/Vicente)\
**Post date:** [May 6, 2006, 10:13pm UTC](https://forum.kirupa.com/t/movie-clip-preloader-with-xml/188356/1 "2006-05-06T22:13:48Z")

</div>

hi!, first, my english is not good, i talk spanish, but this great site makes me learn faster :D.

The question is: i have a dinamic xml gallery with a crossfade effect between images; works fine, but i want change the preloader (a satus bar) for a movie clip with an animation. The code of the gallery is:

function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
description = [];  
url = [];  
enlace = [];  
total = xmlNode.childNodes.length;  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
url\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
}  
id = setInterval(preloadPic, 100);  
} else {  
content = “file not loaded!”;  
}  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“images.xml”);  
var loadTot = 0;  
var k = 0;  
// ///////////////////////////////////  
function preloadPic() {  
clearInterval(id);  
var con = picture.duplicateMovieClip(“con”+k, 9984+k);  
con.loadMovie(image[k]);  
var temp = \_root.createEmptyMovieClip(“temp”+k, 99+k);  
temp.onEnterFrame = function() {  
var total = con.getBytesTotal();  
var loaded = con.getBytesLoaded();  
percent = Math.round((loaded/total\*100)/image.length);  
preloader.preload\_bar.\_xscale = loadTot+percent;  
if (loaded == total && total\>4) {  
con.\_visible = 0;  
nextPic();  
loadTot += percent;  
delete this.onEnterFrame;  
}  
};  
}  
function nextPic() {  
if (k\<image.length-1) {  
k++;  
preloadPic();  
} else {  
firstImage();  
preloader.\_visible = 0;  
info.text = “”;  
}  
}  
listen = new Object();  
listen.onKeyDown = function() {  
if (Key.getCode() == Key.LEFT) {  
prevImage();  
} else if (Key.getCode() == Key.RIGHT) {  
nextImage();  
}  
};  
Key.addListener(listen);  
previous\_btn.onRelease = function() {  
prevImage();  
};  
next\_btn.onRelease = function() {  
nextImage();  
};  
// ///////////////////////////////////  
var p = 0;  
var current;  
MovieClip.prototype.fadeIn = function() {  
if (this.\_alpha\<100) {  
current.\_alpha -= 5;  
this.\_alpha += 5;  
} else {  
current.\_visible = 0;  
delete this.onEnterFrame;  
}  
};  
function nextImage() {  
if (p\<(total-1)) {  
current = this[“con”+p];  
p++;  
var picture = this[“con”+p];  
picture.\_visible = 1;  
picture.\_alpha = 0;  
picture.onEnterFrame = fadeIn;  
desc\_txt.text = description[p];  
url\_txt.text = url[p];  
picture\_num();  
}  
}  
function prevImage() {  
if (p\>0) {  
current = this[“con”+p];  
p–;  
var picture = this[“con”+p];  
picture.\_visible = 1;  
picture.\_alpha = 0;  
picture.onEnterFrame = fadeIn;  
desc\_txt.text = description[p];  
url\_txt.text = url[p];  
picture\_num();  
}  
}  
function firstImage() {  
if (loaded == filesize) {  
con0.\_visible = 1;  
con0.\_alpha = 0;  
con0.onEnterFrame = fadeIn;  
desc\_txt.text = description[0];  
url\_txt.text = url[p];  
pos\_in.text = 1;  
pos\_fin.text = total;  
}  
}  
function picture\_num() {  
current\_pos = p+1;  
pos\_in.text = current\_pos;  
pos\_fin.text = total;  
}

i try many ways, but dont work :S .  
anyone can help me? thanks

---

<div class="post-metadata">

**Author:** ![Vicente](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@Vicente](https://forum.kirupa.com/u/Vicente)\
**Post date:** [May 11, 2006, 11:29pm UTC](https://forum.kirupa.com/t/movie-clip-preloader-with-xml/188356/2 "2006-05-11T23:29:44Z")

</div>

finally, the problem is resolved, the kirupa’s xml gallery with a custom animation preloader…sometimes, i can win :D.

the only limatation is the numbers of frames for the animatoin (100) y suposse what is other problem, but not for now.

here the archives if somebody want it

thx anyway for all, this is a great site!
