Originariamente inviato da frecciak
LOL
fai un test in questo modo..
apri un nuovo documento flash..
- sfondo bianco
- crea due livelli
- in quello sopra al primo frame ci metti tutto il code che ti metto poi sotto..
- nel livello sotto, ma solo nel secondo frame ci metti una immagine a tuo piacere.. con uno stop(); (metti un'immagine pesante per fare il test)
- poi fai Ctrl+Invio due volte per testare il preload
questo è il code per il livello sopra:
codice:
Movieclip.prototype.loader = function(posX, posY, width0, height0, color0) {
this.createEmptyMovieClip("preloading", 1);
preloading.onLoad = function () {
time_1=int(getTimer()/1000);
}
preloading.onEnterFrame = function() {
// Preloading Position
this._x = posX;
this._y = posY;
// Total Bytes loaded / Total Bytes
ptotal = _root.getBytesTotal();
pdown = _root.getBytesLoaded();
// Time Left
time=(getTimer()/1000)-teit_1;
bps= pdown/time;
bytes_left = ptotal-pdown;
leftsek= Math.ceil(bytes_left/bps);
min=Math.floor(leftsek/60);
if(min>=1){
leftsek-= Math.floor(min*60);
if (leftsek < 10){
leftsek= "0"add leftsek;}
}else{
min="0";
if (leftsek < 10){
leftsek= "0"add leftsek;}
}
leftTime = min + ":" + leftsek;
bits = bps/1024;
// BandWide
Kbps = Math.round(bits);
// pourcentage & Ko loaded / Ko total
pourcent = (int((pdown/ptotal)*100));
kodown = Math.round(pdown/1024);
kototal = Math.round(ptotal/1024);
// Preloading barre
this.createEmptyMovieClip("bar2", 3);
this.bar2.lineStyle(1, 0x353535, 90)
this.bar2.moveto(width0, height0);
this.bar2.lineto(width0, 0);
this.bar2.lineto(0, 0);
this.bar2.lineto(0, height0);
this.bar2.lineto(width0, height0);
this.createEmptyMovieClip("bar", 2);
this.bar.beginFill(color0, 80);
this.bar.moveto(pourcent*width0/100, height0);
this.bar.lineto(pourcent*width0/100, 0);
this.bar.lineto(0, 0);
this.bar.lineto(0, height0);
this.bar.lineto(height0, height0);
this.bar.endFill();
// Textfield
this.createTextField("pFeld", 1, -2, 5, 100, 16);
this.pFeld.autoSize = "left";
this.pFeld.selectable = false;
this.pFeld._y += (height0);
// Textfeld Format
this.mForm = new TextFormat();
this.mForm.font = "Arial";
this.mForm.size = 10;
this.mForm.bold = true;
this.mForm.color = 0x353535;
this.pFeld.text = "Chargement : " + pourcent+" %"+"\r"
+kodown+"/"+kototal+" Ko au total"
+ "\rTemps restant : " + leftTime
+ "\rDébit : " + Kbps + " Ko/s" + "\n"
+ "\rOS : " + System.capabilities.os +
"\r" +"Ecran : " + System.capabilities.screenResolutionx +"*"+ System.capabilities.screenResolutiony +
"\r" +"Résolution : " + System.capabilities.screenDPI +
"\r" +"Player version : " + System.capabilities.version +
"\r" +"Langue : " + System.capabilities.language
this.pFeld.setTextFormat(this.mForm);
// Finish Loading
if (ptotal == pdown) {
preloading.removeMovieClip();
_root.nextFrame();
}
};
};
loader(20, 20, 200, 5, 0xCCCCCC);
stop();