ciao a tutti..
vi spiego subito la mia situazione: sito in flash, due scene:
Preloader (il preloader appunto)
Scena_1 (dove sta il sito principale)
in Scena_1 ho 4 pulsanti che caricano 3 loops diversi (files mp3) + lo stop.
nel primo farme di Scena_1 ho il seguente codice:
Codice PHP:
gotoAndStop("news");
s0 = new Sound();
s0.loadSound("music1.mp3", true);
s0.onSoundComplete = function() {
s0.loadSound("music1.mp3", true);
};
pulsante1.enabled = false;
pulsante1.onRelease = function() {
s1 = new Sound();
s2=s3=s0=false;
s1.loadSound("music1.mp3", true);
s1.onSoundComplete = function() {
s1.loadSound("music1.mp3", true);
};
this.enabled = false;
pulsante2.enabled = true;
pulsante3.enabled = true;
off.enabled = true;
};
pulsante2.onRelease= function() {
s2 = new Sound();
s1=s3=s0=false;
s2.loadSound("music2.mp3", true);
s2.onSoundComplete = function() {
s2.loadSound("music2.mp3", true);
};
this.enabled = false;
pulsante1.enabled = true;
pulsante3.enabled = true;
off.enabled = true;
};
pulsante3.onRelease= function() {
s3 = new Sound();
s1=s2=s0=false;
s3.loadSound("music3.mp3", true);
s3.onSoundComplete = function() {
s3.loadSound("music3.mp3", true);
};
this.enabled = false;
pulsante1.enabled = true;
pulsante2.enabled = true;
off.enabled = true;
};
off.onRelease = function() {
s0=s1=s2=s3=false;
this.enabled = false;
pulsante1.enabled = true;
pulsante2.enabled = true;
pulsante3.enabled = true;
};
ho aggiunto una scena e mi sono fatto un preloader con tanto di barra, dati dinamici, ecc.. cercando di capire un pò qua e un pò la come poter fare. il mio intento è quello di caricare col preloader iniziale ANCHE i 3 files mp3.
quindi vedere la barra e i dati che caricano TUTTO, e poi il sito principale (Scena_1)
nel primo frame di Preloader ho buttato giù una cosa del genere:
Codice PHP:
// ........... Carico gli mp3 .........................
s1 = new Sound();
s1.loadSound("music1.mp3", true);
s1.stop();
s2 = new Sound();
s2.loadSound("music2.mp3", true);
s2.stop();
s3 = new Sound();
s3.loadSound("music3.mp3", true);
s3.stop();
// ........... Funzione di calcolo .........................
function calcolo() {
KBtotali = Math.floor((_root.getBytesTotal() + s1.getBytesTotal()+ s2.getBytesTotal()+ s3.getBytesTotal())/1024);
KBcaricati = Math.floor((_root.getBytesLoaded() + s1.getBytesLoaded() + s2.getBytesLoaded() + s3.getBytesLoaded())/1024);
percentuale = Math.floor((KBcaricati/KBtotali)*100);
preloader.barra._xscale = percentuale;
velTrasf = Math.floor(((_root.getBytesLoaded()/1024) - KB)*10)/10;
tempoTrascorso = Math.floor(getTimer()/1000);
tempoRimanente = Math.floor(KBtotali/velTrasf) - Math.floor(KBcaricati/velTrasf);
tempo = getTimer();
KB = _root.getBytesLoaded()/1024;
// ........... Dati dinamici ...............................
preloader.display.htmlText = tempoTrascorso+" seconds passed
"+KBtotali+" KB to be loaded
"+KBcaricati+" KB loaded
"+percentuale+" %"+" loaded"+"
"+velTrasf+" KB/sec
"+tempoRimanente+" seconds left";
}
intervalID = setInterval(calcolo, 500);
// ........... Verifica del caricamento totale .............
if ((_root.getBytesLoaded() + s1.getBytesLoaded() + s2.getBytesLoaded() + s3.getBytesLoaded()) == (_root.getBytesTotal() + s1.getBytesTotal() + s2.getBytesTotal() + s3.getBytesTotal())) {
_root.gotoAndStop ("ini");
clearInterval(intervalID);
}
ho uploadato sul sito e si comporta in modo molto strano, ossia.. carica tutto in un millesimo di secondo, mi va alla scena principale, e il suono dei tasti va a scatti perchè si sta caricanndo man mano tipo in streaming...
potete darmi una mano?