# Preloader to xml items

**URL:** <https://forum.kirupa.com/t/preloader-to-xml-items/279996>\
**Category:** flash\
**Created:** [January 21, 2009, 1:58pm UTC](https://forum.kirupa.com/t/preloader-to-xml-items/279996 "2009-01-21T13:58:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fajota](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@fajota](https://forum.kirupa.com/u/fajota)\
**Post date:** [January 21, 2009, 1:58pm UTC](https://forum.kirupa.com/t/preloader-to-xml-items/279996/1 "2009-01-21T13:58:31Z")

</div>

I have something to make the bar preloader grow in the process of loading.  
All nodes Xml are loaded, but the preloader does not work.

If you can help. Thank you.

The code is this and the files are [[COLOR=Blue]here[/COLOR]](http://www.sgec.com.br/clientes/06/galery.zip):

import flash.display.MovieClip;  
import flash.display.Loader;  
import flash.display.Sprite;  
import flash.net.URLLoader;  
import flash.net.URLRequest;  
import flash.net.navigateToURL;  
import flash.events.Event;  
import flash.events.MouseEvent;  
import flash.events.ProgressEvent;  
import flash.xml.XMLDocument;

// A empty mc created to contain items of XML  
var mcContainer:MovieClip = new MovieClip();  
mcContainer.x = 10;//posicionamos o mcContainer na horizonatl  
mcContainer.y = 33;//posicionamos o mcContainer na vertical  
addChild(mcContainer);

//We created an object q is the mask of mcContainer, the object is in the library mcMask  
var mcMask:Mask = new Mask;  
mcMask.x = 0;  
mcMask.y = 25.4;  
addChild(mcMask);  
mcContainer.mask = mcMask;

//The distance between items  
var posY:uint = 7.7;

//Load of XML  
var urlLoader:URLLoader = new URLLoader();  
urlLoader.load(new URLRequest(“xml/images.xml”));  
urlLoader.addEventListener(Event.COMPLETE, onComplete);

var xml:XML;  
var xmlList:XMLList;

//Function load xml  
function onComplete(evt:Event):void  
{  
xml = new XML(evt.target.data);  
xmlList = xml.children();

trace(xmlList);

for (var i:uint = 0 ; i \< xmlList.length() ; i++)  
{  
//trace(i);

var mcItem:Item = new Item();  
mcItem.y = (mcItem.height + posY) \* i;  
mcItem[“id”] = i;  
mcItem.mcLoader.scaleY = 0;

var loadImage:Loader = new Loader();  
loadImage.load(new URLRequest(xmlList.@path\*));  
//Determine the outcome of the progress of the download file  
loadImage.contentLoaderInfo.addEventListener(Progr essEvent.PROGRESS, loadProgress);  
mcItem.mcImage.addChild(loadImage);

mcItem.mcTitle.txtTitle.text = xmlList.@title\*;  
mcItem.buttonMode = true;  
mcItem.addEventListener(MouseEvent.CLICK, callSite);

mcContainer.addChild(mcItem);  
}  
}

//   
Function to join the links of the items xml  
function callSite(evt:MouseEvent):void  
{  
var callLink:URLRequest = new URLRequest(xmlList.@url[evt.currentTarget[“id”]]);  
navigateToURL(callLink, “\_blank”);  
}

//Function to make the bar loading works  
function loadProgress(evt ![](http://forum.kirupa.com/uploads/kirupa/5115/373eb333a028f173.gif)rogressEvent):void  
{  
trace(Number(evt.bytesLoaded) / Number(evt.bytesTotal));  
mcContainer.mcItem.mcLoader.scaleY = evt.bytesLoaded / evt.bytesTotal;  
}
