Comunidad de diseño web y desarrollo en internet online

Carga secuencial de archivos externos (swf, jpg....etc)

Citar            
MensajeEscrito el 01 Feb 2011 12:20 pm
Hola,
últimamente me encuentro a menudo con el mismo problema cuando quiero hacer la carga de una sucesión de archivos externos (en éste caso concreto son SWF) y almacenarlos secuencialmente. Estoy leyendo una serie de datos externos relativos a objetos (ésto no es problema, no hagáis mucho caso a como tomo los datos de la BBDD). La idea es ir almacenado los datos y los SWF en un array para utilizarlo cuando convenga.Con un solo elemento no hay problema pero con varios sí....
Si utilizo el listener que atiende a la carga completa del archivo externo y quiero ir almacenando el archivo que estoy cargando para ubicarlo en la posición del Array correspondiente no es posible identificarlo. Me he creado una variable global indexBuilding pero no se actualiza bien.
Creo que es algo muy básico que debería porderse hacer sin problema pero no puedo....
Gracias de antemano!!

Código ActionScript :

public function parseBuildings(buildings:ISFSObject):void {
      
   var buildingObj:Object; 
   var bbuildings:ISFSArray;   
   bbuildings = buildings.getSFSArray("buildings"); 
   buildingsData = new Array();
         
   for (var i:int = 0; i < bbuildings.size(); i++) {
            
      //Save building info from BBDD
      buildingObj = new Object(); 
      buildingObj.sizex = bbuildings.getSFSObject(i).getInt("sizex"); 
      buildingObj.sizey = bbuildings.getSFSObject(i).getInt("sizey"); 
      buildingObj.x = bbuildings.getSFSObject(i).getInt("x"); 
      buildingObj.y = bbuildings.getSFSObject(i).getInt("y"); 
      buildingObj.filename = pathFile+bbuildings.getSFSObject(i).getUtfString("filename")+".swf";
      buildingObj.o = bbuildings.getSFSObject(i).getInt("o");
      buildingObj.name = bbuildings.getSFSObject(i).getUtfString("name");
      buildingsData[i] = buildingObj; 
      indexBuilding = i; 
      loadSwfBuildings(i); 
            
   }//end 'for'
}
//FUNCTION: 
public function loadSwfBuildings(_indexBuilding:int):void {         
 //Loader object
 var loader:Loader = new Loader();         
//Config listeners 'contentLoaderInfo' has the info about the file
initLoaderListeners(loader.contentLoaderInfo);         
//Request object
var request:URLRequest = new URLRequest(buildingsData[_indexBuilding].filename);         
//Load request
loader.load(request);      
}
//FUNCTION:    
private function initLoaderListeners(dispatcher:IEventDispatcher):void {
  dispatcher.addEventListener(Event.COMPLETE, completeHandler);
  dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
  dispatcher.addEventListener(Event.INIT, initHandler);
  dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  dispatcher.addEventListener(Event.OPEN, openHandler);
  dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);         
}
//FUNCTION: 
//--------This method is executed when download is finished
private function completeHandler(event:Event):void {
   trace("completeHandler: " + event);   
   //Save Timeline content [MovieClip]-> building
   buildingHolder = event.target.content;
   buildingData[indexBuilding].element=buildingHolder; ->>Aquí tengo el problema el valor de indexBuilding no se actualiza correctamente de manera secuencial!!!!
//o en un array de MovieClips (previamente declarado)->Tampoco
buildingSwf[indexBuilding]=buildingHolder; 
         
}

Por emedmaria

73 de clabLevel



 

chrome
Citar            
MensajeEscrito el 01 Feb 2011 01:27 pm
BuenAS:

Echa un vistazo a BulkLoader o LoaderMax.

En ambos puedes crearte una cola de assets a cargar, y recuperar el asset concreto que te interese en cualquier momento. En el caso de LoaderMax incluso tienes la posibilidad de pausar la carga (por ejemplo, si el usuario empieza a cargar una sección de tu site, y cambia a otra antes de que acabe) y reanudarla más tarde.

Un saludo.

Por Lukánicos

Claber

468 de clabLevel



Genero:Masculino  

chrome
Citar            
MensajeEscrito el 01 Feb 2011 01:36 pm
Gracias!! Voy a darle un vistazo :)

Por emedmaria

73 de clabLevel



 

chrome
Citar            
MensajeEscrito el 01 Feb 2011 03:15 pm
MIL GRACIAS!!!!
He optado por el BulkLoader porque me parecía más sencillo y me ha servido! Con la de horas que llevaba dándole vueltas....

Por emedmaria

73 de clabLevel



 

chrome

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.