Encontre una ya hecha en:
http://www.flashscript.biz/components/xmlpreloader/xmlpreload.html
Es un MXP
Sólo me falta lanzarlo al frame 2 cuando todos los XML están cargados. Dice así:
[CODE]
#initclip
//class definition
XmlPreloader.prototype = new MovieClip();
function XmlPreloader(){
//defining var for filename
fName = "clipping.xml"; //fName =
this.fileOneName;
//loading xml
myXML = new XML();
myXML.load(fName);
myXML.onLoad = function(success){
if(success){
//trace(this.getBytesTotal());
}
}
//function to continue loading next file
this.upDate1();
//function to show the bytes
this.countBytes();
}
//function to make counter invisible
XmlPreloader.prototype.onLoad = function(){
inVisible = this.iVis;
if(inVisible){
this._visible = false;
}
}
//function to count the bytes
XmlPreloader.prototype.countBytes = function(){
this.onEnterFrame = function(){
var loadedBytes = myXML.getBytesLoaded();
var totalBytes = myXML.getBytesTotal();
var bytes = Math.ceil((loadedBytes/1024)*1000);
var percentLoaded = Math.ceil((loadedBytes/totalBytes) * 100);
this.clipLoader.totalBox.text = bytes + " bytes";
this.clipLoader.loadBox.text = percentLoaded + " %";
if(loadedBytes>=totalBytes){
percentLoaded = 101;
}
}
}
//all the update functions follow
XmlPreloader.prototype.upDate1 = function(){
fName = "documentos.xml";
if(fName != "defaultValue"){
myXML = new XML();
myXML.load(fName);
myXML.onLoad = function(success){
if(success){
//trace(this.getBytesTotal());
}
}
}
this.upDate2();
this.countBytes();
}
XmlPreloader.prototype.upDate2 = function(){
fName = "informa.xml";
if(fName != "defaultValue"){
myXML = new XML();
myXML.load(fName);
myXML.onLoad = function(success){
if(success){
//trace(this.getBytesTotal());
}
}
}
this.upDate3();
this.countBytes();
}
XmlPreloader.prototype.upDate3 = function(){
fName = "quemsomos.xml";
if(fName != "defaultValue"){
myXML = new XML();
myXML.load(fName);
myXML.onLoad = function(success){
if(success){
//trace(this.getBytesTotal());
}
}
}
this.upDate4();
this.countBytes();
}
XmlPreloader.prototype.upDate4 = function(){
fName = "template.xml";
if(fName != "defaultValue"){
myXML = new XML();
myXML.load(fName);
myXML.onLoad = function(success){
if(success){
trace(this.getBytesTotal());
}
}
}
this.upDate5();
this.countBytes();
}
Object.registerClass("XmlPreloader", XmlPreloader);
#endinitclip
[/CODE]
_____________
Fernando Comet
www.fernandocomet.com<http://www.fernandocomet.com>
----------------------------------------
> From: [EMAIL PROTECTED]
> To: [email protected]
> Date: Mon, 6 Nov 2006 14:18:32 +0100
> Subject: Re: [ASNativos] Precarga XML dinámicos
>
> Algo asi te deberia de funcionar (no he probado el codigo):
>
> <code>
> var urls:Array =
> ["fichero1.xml","fichero2.xml","fichero3.xml","fichero4.xml","fichero5.xml"]
> ;
> var loaded:Array = [0,0,0,0,0];
> var xmls:Array = new Array();
> var index:Number = -1;
> var framer:MovieClip = _root.createEmptyMovieClip("framer",12345);
> function iniciar(){
> framer.onEnterFrame = preload;
> cargarSiguiente();
> }
> function cargarSiguiente(){
> index++;
> if(index==urls.length){
> framer.onEnterFrame = null;
> framer.removeMovieClip();
> trace("fin");
> parseData();
> return;
> }
> xmls[index] = new XML();
> xmls[index].ignoreWhite = true;
> xmls[index].load(urls[index]);
> }
> function preload(){
> loaded[index] =
> (xmls[index].getBytesLoaded()*100)/xmls[index].getBytesTotal();
> var total:Number = 0;
> for(var i:Number = 0;i<loaded.length;i++){
> total += loaded[i];
> }
> total /= 5;
> trace("Cargado "+total+"%");
> if(loaded[index]==100){
> cargaSiguiente();
> }
> }
> function parseData(){
> // Codigo de parseo de XML
> }
>
> iniciar();
> </code>
>
> Un saludo,
>
> Joseba
>
> > -----Mensaje original-----
> > De: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] En nombre de Fernando Sáez Comet
> > Enviado el: lunes, 06 de noviembre de 2006 11:46
> > Para: [email protected]
> > Asunto: [ASNativos] Precarga XML dinámicos
> >
> > Hola Nativos!Tengo 6 XML dinámicos que se cargan a la vez y
> > estoy recopilando info para hacer una precarga conjunta ya
> > que una normal no vale.He
> > visto:http://livedocs.macromedia.com/flash/8_es/main/wwhelp/ww
> himpl/js/html/wwhelp.htm?href=00001501.htmlhttp://www.mail->
> archive.com/[email protected]/msg03878.htmlMe interesa saber
> > si habeis hecho algo parecido.GraciasFernando
> > Cometwww.fernandocomet.com
> > _________________________________________________________________
> > Prueba algunos de los nuevos servicios en línea que te ofrece
> > Windows Live Ideas: tan nuevos que ni siquiera se han
> > publicado oficialmente todavía.
> > http://ideas.live.com
> > -----------------------------------------------------
> > ASNativos
> > www.5dms.com
> > subscripciones/desubscripciones
> > http://asnativos.5dms.com
> > -----------------------------------------------------
>
>
> -----------------------------------------------------
> ASNativos
> www.5dms.com
> subscripciones/desubscripciones
> http://asnativos.5dms.com
> -----------------------------------------------------
_________________________________________________________________
Prueba algunos de los nuevos servicios en línea que te ofrece Windows Live
Ideas: tan nuevos que ni siquiera se han publicado oficialmente todavía.
http://ideas.live.com
-----------------------------------------------------
ASNativos
www.5dms.com
subscripciones/desubscripciones
http://asnativos.5dms.com
-----------------------------------------------------