Hi all,
I’ve been searching for hours now but I haven’t found anything.
What I’m trying to do is get the total bytes of all the files I want to load and display the percentage loaded of total bytes and bytes loaded of all the files.
Its a slideshow so i want all the files loaded and then it will play.
I’ve looked at bulk-loader but it wasn’t what I needed.
The image are loaded from an xml file. I think I would need to create an Array and then find out the total bytes but I don’t know how to reference the loader in the progress.
here is the code:
private function loadImages():void {
//Loop through the images in the xml file and then load them
for (var i:int = 0; i < totalItems; i++) {
//Create a new loader to every image.
imageLoader = new Loader();
//Load the images
imageLoader.load(new URLRequest(xmlList*.@src));
//Call fucntion imageLoading when images are being loaded
imageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, imageLoading);
// Call function imageLoaded when the images are loaded
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
}//loop
}//loadImages
private function imageLoading(evt:ProgressEvent):void {
// work out whay has been loaded
totalLoaded = Math.round((evt.bytesLoaded / evt.bytesTotal) * 100);
//add results of totalLoaded in to tPercent
tPercent.text = totalLoaded + "%"+" " + Math.round((evt.bytesTotal))/1000;
//x and y of tPercent
tPercent.x = stage.stageWidth / 2 - tPercent.width/2;
tPercent.y= 350;//stage.stageHeight / 2 - tPercent.height/2;
//set text format
tPercent.setTextFormat(tfPercent);
//add tPercent to stage
addChild(tPercent);
}
If someone could just tell me the how it would work i should be able to figure it out.
thanks
vxd