Visualizzazione dei risultati da 1 a 9 su 9
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    167

    semplificare del codice

    scrivo questo, ci sarebbe un modo per semplificare il tutto

    riproduzione1=true;
    riproduzione2=true;
    riproduzione3=true;
    riproduzione4=true;
    riproduzione5=true;
    riproduzione6=true;
    riproduzione7=true;
    riproduzione8=true;
    riproduzione9=true;
    riproduzione10=true;
    riproduzione11=true;
    riproduzione12=true;
    riproduzione13=true;
    riproduzione14=true;
    riproduzione15=true;
    riproduzione16=true;
    riproduzione17=true;
    riproduzione18=true;

    s1 = new Sound();
    s2 = new Sound();
    s3 = new Sound();
    s4 = new Sound();
    s5 = new Sound();
    s6 = new Sound();
    s7 = new Sound();
    s8 = new Sound();
    s9 = new Sound();
    s10 = new Sound();
    s11 = new Sound();
    s12 = new Sound();
    s13 = new Sound();
    s14 = new Sound();
    s15 = new Sound();
    s16 = new Sound();
    s17 = new Sound();
    s18 = new Sound();

    s1.loadSound("audio1/file1.mp3",false);
    s2.loadSound("audio1/file2.mp3",false);
    s3.loadSound("audio1/file3.mp3",false);
    s4.loadSound("audio1/file4.mp3",false);
    s5.loadSound("audio1/file5.mp3",false);
    s6.loadSound("audio1/file6.mp3",false);
    s7.loadSound("audio1/file7.mp3",false);
    s8.loadSound("audio1/file8.mp3",false);
    s9.loadSound("audio1/file9.mp3",false);
    s10.loadSound("audio1/file10.mp3",false);
    s11.loadSound("audio1/file11.mp3",false);
    s12.loadSound("audio1/file12.mp3",false);
    s13.loadSound("audio1/file13.mp3",false);
    s14.loadSound("audio1/file14.mp3",false);
    s15.loadSound("audio1/file15.mp3",false);
    s16.loadSound("audio1/file16.mp3",false);
    s17.loadSound("audio1/file17.mp3",false);
    s18.loadSound("audio1/file18.mp3",false);

    audio1.onRelease=function(){
    if(riproduzione1){
    s1.start(0,1);
    s2.stop();
    s3.stop();
    s4.stop();
    s5.stop();
    s6.stop();
    s7.stop();
    s8.stop();
    s9.stop();
    s10.stop();
    s11.stop();
    s12.stop();
    s13.stop();
    s14.stop();
    s15.stop();
    s16.stop();
    s17.stop();
    s18.stop();
    riproduzione1 = false;
    riproduzione2 = true;
    riproduzione3=true;
    riproduzione4=true;
    riproduzione5=true;
    riproduzione6=true;
    riproduzione7=true;
    riproduzione8=true;
    riproduzione9=true;
    riproduzione10=true;
    riproduzione11=true;
    riproduzione12=true;
    riproduzione13=true;
    riproduzione14=true;
    riproduzione15=true;
    riproduzione16=true;
    riproduzione17=true;
    riproduzione18=true;
    }
    };

    audio2.onRelease=function(){
    if(riproduzione2){
    s2.start(0,1);
    s1.stop();
    s3.stop();
    s4.stop();
    s5.stop();
    s6.stop();
    s7.stop();
    s8.stop();
    s9.stop();
    s10.stop();
    s11.stop();
    s12.stop();
    s13.stop();
    s14.stop();
    s15.stop();
    s16.stop();
    s17.stop();
    s18.stop();
    riproduzione2 = false;
    riproduzione1 = true;
    riproduzione3=true;
    riproduzione4=true;
    riproduzione5=true;
    riproduzione6=true;
    riproduzione7=true;
    riproduzione8=true;
    riproduzione9=true;
    riproduzione10=true;
    riproduzione11=true;
    riproduzione12=true;
    riproduzione13=true;
    riproduzione14=true;
    riproduzione15=true;
    riproduzione16=true;
    riproduzione17=true;
    riproduzione18=true;
    }
    };

    e cosi via

  2. #2
    codice:
    var quanti = 18;
    for( var a = 1; a <= quanti; a++ ) {
    	var b = String(a);
    	_root['riproduzione'+b] = true;
    	_root['s'+b] = new Sound();
    	_root['s'+b].loadSound( 'audio1/file'+b+'.mp3' ,false);
    	_root['audio'+b].__check = b;
    	_root['audio'+b].onRelease=function(){
    		if( _root['riproduzione'+this.__check] ) {
    			for( var a = 1; a <= _root.quanti; a++ ) {
    				var b = String( a );
    				if( Number( this.__check ) == a ) {
    					_root['riproduzione'+this.__check] = false; 
    					_root['s'+this.__check].start(0,1);
    				}
    				else {
    					_root['riproduzione'+this.__check] = true; 
    					_root['s'+b].stop();
    				}
    			}
    		}
    	}
    }
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

  3. #3
    ma creare un solo oggetto sound e gestire quello non è più semplice secondo te andr3a?

    regalami un oggi da favola...e il domani bhe!?non mi importa se tu 6 con me! ©Ily

  4. #4
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    167
    poichè mi trovo in un mc dovrei sostituire this a _root

    ma credo che non funzioni

    per yassassin

    è lo stesso mc del suggerimento a cui mi hai risposto prima

    m sta scumbinann

  5. #5
    Originariamente inviato da Yassassin
    ma creare un solo oggetto sound e gestire quello non è più semplice secondo te andr3a?
    si ma se lui ha bisogno di fare quello io quello gli ho risolto


    codice:
    this.quanti = 18;
    for( var a = 1; a <= this.quanti; a++ ) {
    	var b = String(a);
    	this['riproduzione'+b] = true;
    	this['s'+b] = new Sound();
    	this['s'+b].loadSound( 'audio1/file'+b+'.mp3' ,false);
    	this['audio'+b].__path = this;
    	this['audio'+b].__check = b;
    	this['audio'+b].onRelease=function(){
    		if( this.__path['riproduzione'+this.__check] ) {
    			for( var a = 1; a <= this.__path.quanti; a++ ) {
    				var b = String( a );
    				if( Number( this.__check ) == a ) {
    					this.__path['riproduzione'+this.__check] = false; 
    					this.__path['s'+this.__check].start(0,1);
    				}
    				else {
    					this.__path['riproduzione'+this.__check] = true; 
    					this.__path['s'+b].stop();
    				}
    			}
    		}
    	}
    }
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

  6. #6
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    167
    scusa l'ignoranza

    al posto di __path metto il nome del mc di destinazione ovvero clip3

    al posto di __check

    poi scusami l'ultima cosa

    se guardi il post forum.html.it/forum/showthread.php?threadid=790543&goto=newpost
    puoi notare che io mi ricavo i bottoni tramite action script quindi al posto di this['audio'+b] dovrei mettere this['clipaudio'+b]

    ciao

  7. #7
    i moni te li gestisci come ti pare ... cambia i prefissi e non modificare altro ... al posto di __path lasci path , non puoi provarlo con i giusti suffissi prima di modificarlo ?

    oppure posti il vero codice che stai usando , specificando dov'e' e dove sono le altre cose ...

    io mica posso sapere tutto
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

  8. #8
    Utente di HTML.it
    Registrato dal
    Feb 2002
    Messaggi
    167
    funziona non preoccuparti e grazie

    per curiosità ti posto il codice

    function Audioattach() {
    k = 0;
    conteggio = 0;
    for (i=1; i<19; i++) {
    attachMovie("clipaudio", "clipaudio"+i, i);
    this["clipaudio"+i]._x = 15;
    this["clipaudio"+i]._y = 25+k*18;
    conteggio++;
    k++;
    }
    }
    Audioattach();

    this.quanti = 18;
    for( var a = 1; a <= this.quanti; a++ ) {
    var b = String(a);
    this['riproduzione'+b] = true;
    this['s'+b] = new Sound();
    this['s'+b].loadSound( 'audio1/file'+b+'.mp3' ,false);
    this['clipaudio'+b].clip3 = this;
    this['clipaudio'+b].__check = b;
    this['clipaudio'+b].onRelease=function(){
    if( this.clip3['riproduzione'+this.__check] ) {
    for( var a = 1; a <= this.clip3.quanti; a++ ) {
    var b = String( a );
    if( Number( this.__check ) == a ) {
    this.clip3['riproduzione'+this.__check] = false;
    this.clip3['s'+this.__check].start(0,1);
    }
    else {
    this.clip3['riproduzione'+this.__check] = true;
    this.clip3['s'+b].stop();
    }
    }
    }
    }
    }

  9. #9
    Originariamente inviato da emmebbì
    funziona non preoccuparti e grazie
    di nulla
    Formaldehyde a new Ajax PHP Zero Config Error Debugger

    WebReflection @WebReflection

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.