Originariamente inviato da Broly
Beh ma se vuoi ricrearlo basta anche come hai fatto tu un altro brano = new Sound() , che sovrascriverà in automatico quello precedente
praticamente è quello che faccio...
LINK PROVA
Alla pressione dei pulsanti 2,3,4 siverificano questi eventi:
- annullo (con clearInterval ) la funzione relativa al loading.
- annullo la funzione relativa al puntatore di posizione del brano
- e richiamo questa funzione per ricreare il nuovo brano:
codice:
function Loop(){
cf_barra._alpha = 0;
brano = new Sound();
brano.loadSound(nome_brano, true);
brano.setVolume(i);
loading = setInterval(PreLoad, 50);
clearInterval(this);
}
ma come puoi notare dal link si "ingrippa" (
) l'swf. A tal proposito ho pensato di eliminare l'oggetto Sound alla pressione dei pls, e di ricrearlo al rilascio dei pls....
ma nulla da fare
te riesci ad intuire l'errore tramite il link che ho postato?
cmq questo è tutto il codice in as:
codice:
i = 50;
cf_mask._xscale = Math.round((85*i)/85);
nome_brano = "loop1.mp3";
brano = new Sound();
brano.loadSound(nome_brano, true);
brano.setVolume(i);
cf_puntatore._alpha = 0;
cf_barra._alpha = 0;
larghezza = 100;
loading = setInterval(PreLoad, 50);
cf_pls1.gotoAndStop ("attivo");
cf_pls_play.gotoAndStop("attivo");
function Puntatore(){
cf_puntatore._alpha = 100;
time_par = brano.position;
time_tot = brano.duration;
perc = Math.round((time_par*100)/time_tot);
setProperty ("cf_puntatore", _xscale, (perc*larghezza)/100);
setProperty ("cf_puntatore", _x, -76.5);
if (time_par == time_tot) {
brano = new Sound();
brano.loadSound(nome_brano, true);
brano.setVolume(i);
}
}
function Loop(){
cf_barra._alpha = 0;
brano = new Sound();
brano.loadSound(nome_brano, true);
brano.setVolume(i);
loading = setInterval(PreLoad, 50);
clearInterval(leggi_loop);
}
function PreLoad(){
car = brano.getBytesLoaded();
tot = brano.getBytesTotal();
perc = Math.round((car*100)/tot);
setProperty ("cf_barra", _xscale, (perc*larghezza)/100);
setProperty ("cf_barra", _x, -76.5);
if (car>1024) {
setProperty ("cf_barra", _alpha, 100);
tempo_brano = setInterval(Puntatore, 50);
if (car == tot ) {
clearInterval(loading);
}
}
}
// pls1:
cf_pls1.onRollOver = function(){
this.play();
}
cf_pls1.onRollOut = function(){
this.gotoAndStop("1");
}
cf_pls1.onPress = function() {
if(_root.piatto.braccio._currentframe == stoppa){
_root.piatto.braccio.gotoAndPlay(1);
}else{
_root.piatto.braccio.gotoAndPlay("nuovo");
}
cf_pls_play.gotoAndStop("attivo");
cf_pls_stop.gotoAndStop(1);
cf_pls3.gotoAndStop(1);
cf_pls2.gotoAndStop(1);
cf_pls4.gotoAndStop(1);
clearInterval(loading);
brano.stop();
}
cf_pls1.onRelease = function(){
nome_brano = "loop1.mp3";
leggi_loop = setInterval(Loop, 100);
this.gotoAndStop("attivo");
}
cf_pls1.onReleaseOutside = function(){
nome_brano = "loop1.mp3";
leggi_loop = setInterval(Loop, 100);
this.gotoAndStop("attivo");
}
// pls2:
cf_pls2.onRollOver = function(){
this.play();
}
cf_pls2.onRollOut = function(){
this.gotoAndStop("1");
}
cf_pls2.onPress = function() {
if(_root.piatto.braccio._currentframe == stoppa){
_root.piatto.braccio.gotoAndPlay(1);
}else{
_root.piatto.braccio.gotoAndPlay("nuovo");
}
cf_pls_play.gotoAndStop("attivo");
cf_pls_stop.gotoAndStop(1);
cf_pls1.gotoAndStop(1);
cf_pls3.gotoAndStop(1);
cf_pls4.gotoAndStop(1);
clearInterval(loading);
brano.stop();
}
cf_pls2.onRelease = function(){
nome_brano = "loop2.mp3";
leggi_loop = setInterval(Loop, 100);
this.gotoAndStop("attivo");
}
cf_pls2.onReleaseOutside = function(){
nome_brano = "loop2.mp3";
leggi_loop = setInterval(Loop, 100);
this.gotoAndStop("attivo");
}
//pls3:
cf_pls3.onRollOver = function(){
this.play();
}
cf_pls3.onRollOut = function(){
this.gotoAndStop("1");
}
cf_pls3.onPress = function() {
if(_root.piatto.braccio._currentframe == stoppa){
_root.piatto.braccio.gotoAndPlay(1);
}else{
_root.piatto.braccio.gotoAndPlay("nuovo");
}
cf_pls_play.gotoAndStop("attivo");
cf_pls_stop.gotoAndStop(1);
cf_pls1.gotoAndStop(1);
cf_pls2.gotoAndStop(1);
cf_pls4.gotoAndStop(1);
clearInterval(loading);
brano.stop();
}
cf_pls3.onRelease = function(){
nome_brano = "loop3.mp3";
leggi_loop = setInterval(Loop, 100);
this.gotoAndStop("attivo");
}
cf_pls3.onReleaseOutside = function(){
nome_brano = "loop3.mp3";
leggi_loop = setInterval(Loop, 100);
this.gotoAndStop("attivo");
}
//pls3:
cf_pls4.onRollOver = function(){
this.play();
}
cf_pls4.onRollOut = function(){
this.gotoAndStop("1");
}
cf_pls4.onPress = function() {
if(_root.piatto.braccio._currentframe == stoppa){
_root.piatto.braccio.gotoAndPlay(1);
}else{
_root.piatto.braccio.gotoAndPlay("nuovo");
}
cf_pls_play.gotoAndStop("attivo");
cf_pls_stop.gotoAndStop(1);
cf_pls1.gotoAndStop(1);
cf_pls2.gotoAndStop(1);
cf_pls3.gotoAndStop(1);
clearInterval(loading);
brano.stop();
}
cf_pls4.onRelease = function(){
nome_brano = "loop4.mp3";
leggi_loop = setInterval(Loop, 100);
this.gotoAndStop("attivo");
}
cf_pls4.onReleaseOutside = function(){
nome_brano = "loop4.mp3";
leggi_loop = setInterval(Loop, 100);
this.gotoAndStop("attivo");
}
//pls stop:
cf_pls_stop.onRollOver = function(){
this.play();
}
cf_pls_stop.onRollOut = function (){
this.gotoAndStop(1);
}
cf_pls_stop.onPress = function (){
brano.stop();
clearInterval(loading);
cf_pls_play.gotoAndStop(1);
}
cf_pls_stop.onRelease = function(){
this.gotoAndStop("attivo");
}
cf_pls_stop.onReleaseOutside = function(){
this.gotoAndStop("attivo");
}
//pls play:
cf_pls_play.onRollOver = function (){
this.play();
}
cf_pls_play.onRollOut = function (){
this.gotoAndStop(1);
}
cf_pls_play.onPress = function (){
brano.start();
loading = setInterval(PreLoad, 50);
cf_pls_stop.gotoAndStop(1);
}
cf_pls_play.onRelease = function(){
this.gotoAndStop("attivo");
}
cf_pls_play.onReleaseOutside = function(){
this.gotoAndStop("attivo");
}