# \[flash8\] need preloader for .xml file images

**URL:** <https://forum.kirupa.com/t/flash8-need-preloader-for-xml-file-images/214694>\
**Category:** flash\
**Created:** [January 31, 2007, 5:46am UTC](https://forum.kirupa.com/t/flash8-need-preloader-for-xml-file-images/214694 "2007-01-31T05:46:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blacey777](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@blacey777](https://forum.kirupa.com/u/blacey777)\
**Post date:** [January 31, 2007, 5:46am UTC](https://forum.kirupa.com/t/flash8-need-preloader-for-xml-file-images/214694/1 "2007-01-31T05:46:49Z")

</div>

Hi,  
I am new to actionscript and am currently using the following script to load 25 images into a movieclip container (“lgpicture”) from an external .xml file. The problem is that each image loads individually and there is a long pause between viewing each image for the first time. Instead I would like, if possible, to use a preloader that will load all images at once, before any image is viewed with a percentage bar or something like that. I am unfortunately unable to compromise on the image size (some well over 500K) but one long pause in the beginning is much more favorable than pausing between each image. I would really appreciate any help I can get!!!

code:

lgpicture.\_x=0;

lgpicture.\_y=30;

function loadXML(loaded) {

if (loaded) {

xmlNode = this.firstChild;

image = [];

description = [];

total = xmlNode.childNodes.length;

for (i=0; i\<total; i++) {

image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;

description\* = xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;

}

firstImage();

} else {

content = “file not loaded!”;

}

}

xmlData = new XML();

xmlData.ignoreWhite = true;

xmlData.onLoad = loadXML;

xmlData.load(“images1lg.xml”);

/////////////////////////////////////

/////////////////////////////////////

p = 0;

this.onEnterFrame = function() {

filesize = lgpicture.getBytesTotal();

loaded = lgpicture.getBytesLoaded();

preloader.\_visible = true;

if (loaded != filesize) {

preloader.preload\_bar.\_xscale = 100\*loaded/filesize;

} else {

preloader.\_visible = false;

if (lgpicture.\_alpha\<100) {

lgpicture.\_alpha += 10;

}

}

};

function firstImage() {

if (loaded == filesize) {

lgpicture.\_alpha = 0;

lgpicture.loadMovie(image[0], 1);

desc\_txt.text = description[0];

lgpicture\_num();

}

}

function lgpicture\_num() {

current\_pos = p+1;

pos\_txt.text = current\_pos+" / "+total;

}
