Hey plp!!
guys i need a little help here,im trying to create an advert box that loads different files from urls contained in an external xml src.
The code for the XML loading works well, but the rest of the code does not seem to work.
what im trying to archieve is:
- get the list of urls from the XML file
- trigger the loading of these files as soon as the xml file is loaded
- loop among these files (5 in total), in a given period of time,
- Each time they are loaded ,the loading bar should show the progress
here is my code (sorry its not organised ) :
_root.start_load_advert = function() {
load_advert_int = setInterval(load_advert, 10000);
};
load_advert = function () {
if (current_advert == undefined || current_advert == 6) {
current_advert = 1;
}
mcLoader.loadClip(_root["advert"+current_advert].url,container);
current_advert++;
};
function loadXML(loaded) {
if (loaded) {
i = 0;
while (i<=5) {
new_name = "advert"+(i+1);
_root[new_name] = new Array();
_root[new_name].url = this.firstChild.childNodes*.childNodes[0].firstChild.nodeValue;
_root[new_name].link = this.firstChild.childNodes*.childNodes[1].firstChild.nodeValue;
i++;
}
load_advert();
} else {
trace("file not loaded!");
; ;
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://agmitre.vze.com/laconic/advert/large_advert_db.xml");
var container:MovieClip = this.createEmptyMovieClip("container", _root.getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
B = bytesLoaded;
A = bytesTotal;
percentage = (B/A)*100;
loader._width = (percentage/100)*580;
clearInterval(load_advert_int);
trace(percentage);
};
listener.onLoadInit = function(target:MovieClip):Void {
mc_width = container._width;
mc_height = container._height;
container._x = (590-mc_width)/2;
container._y = (590-mc_height)/2;
removeMovieClip(sub_container);
container.duplicateMovieClip("sub_container",_root.getNextHighestDepth());
_root.start_load_advert();
};
mcLoader.addListener(listener);
loader._x = 5;
loader._alpha = 10;
stop();
NB:The code for the progress bar works when loading a single file using
mcLoader.loadClip(“URL”,container);
THX ALOT
AG