PB loader

tom1gson Messages postés 5 Date d'inscription mardi 8 novembre 2005 Statut Membre Dernière intervention 22 juin 2006 - 13 juin 2006 à 19:27
tom1gson Messages postés 5 Date d'inscription mardi 8 novembre 2005 Statut Membre Dernière intervention 22 juin 2006 - 15 juin 2006 à 10:51
Bonjour,
Debutant je crée mon site en flash...
J'ai un probleme avec mon preloader...
Le swf que je charge a partir d'un autre se lance avant les 100%, en surimpression sur la barre de chargement...
Voici le code que j'ai utilisé pour le preloader :
_root.loadMovieClip=function(nom_fichier,niveau)
 {
 trace("chargement");
 _root.barre_chargement.fichier=nom_fichier;
 _root.barre_chargement._visible=true;
 _root.tdebut=new Date;
 mon_mcl = new MovieClipLoader();
 _root.mon_mcl.loadClip(nom_fichier, "_level" + niveau);
 _root.barre_chargement.niveau=niveau;
 _root.barre_chargement._max=taille_max;
 _root.i=0;
 _root.barre_chargement.onEnterFrame=function()
  {_root.i++;
  
  var loadProgress = _root.mon_mcl.getProgress("_level" + this.niveau);
  d=new Date;
  heure_deb=_root.tdebut.getTime();
  temppasse=d.getTime()-heure_deb;
  temptotalestime=temppasse*(loadProgress.bytesTotal/loadProgress.bytesLoaded);
  temprestantestime=temptotalestime-temppasse;
  debit=Math.ceil((loadProgress.bytesLoaded/1024)/(temppasse/1000));
  
  
  _root.barre_chargement.debit=debit + " Ko/s";
  
  _root.barre_chargement.taille_telecharger=Math.ceil(loadProgress.bytesLoaded/1024) + " Ko"
  
  h=Math.floor(temprestantestime/1000/60/60);
  m=Math.floor(temprestantestime/1000/60);
  s=Math.ceil(temprestantestime/1000);
  h<10?h="0" + h:null;
  m<10?m="0" + m:null;  
  s<10?s="0" + s:null;    
  
  _root.barre_chargement.temp_restant=h + ":" + m + ":" + s;
  
  _root.barre_chargement.temp_passe=Math.ceil(temppasse/1000) + " s / " + Math.ceil(temptotalestime/1000) + " s";
  
  _root.barre_chargement.temptotalestime=Math.ceil(temptotalestime);
  
  _root.barre_chargement.taille_totale=Math.ceil(loadProgress.bytesTotal/1024) + " Ko";
  if(loadProgress.bytesLoaded!=undefined and loadProgress.bytesTotal!=undefined)
   {
   ratio=Math.ceil((loadProgress.bytesLoaded*100)/loadProgress.bytesTotal);
   _root.barre_chargement.ratio.text= ratio + "%";
   }
  else
   _root.barre_chargement.ratio.text= "0 %";
  //_root.barre_chargement.ratio._x=(3*ratio);
  _root.barre_chargement.progressbar._width=(temppasse/temptotalestime)*300;
  if((loadProgress.bytesLoaded==loadProgress.bytesTotal) and loadProgress.bytesTotal>0)
   {
   _root.barre_chargement._visible=false;
   delete this.onEnterFrame;
   _root.chargeur._alpha=100;
   }
  }
 }
_root.loadMovieClip("monurl + loader.swf",1);

Merci d'avance...

1 réponse

tom1gson Messages postés 5 Date d'inscription mardi 8 novembre 2005 Statut Membre Dernière intervention 22 juin 2006
15 juin 2006 à 10:51
Bon devant le manque cru de solidarité...
Voila la solution a mon probleme...
Il faut rajouter ces qq lignes de code sur la premiere image du swf à charger, quitte à decaler l'animation d'une image vers la droite sur la timeline...
stop();
_root.onEnterFrame=function()
{
if(_root.getBytesLoaded()>=_root.getBytesTotal())
{
delete _root.onEnterFrame;
_root.gotoAndPlay(1);
}
}
0
Rejoignez-nous