Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 18
  1. #1

    problema ridondanza codice.

    ciao a tutti ragazzi,

    ho un grosso problema di ridondanza codice per un menù, e non riesco ad uscirne da solo, per questo chiedo se qualcuno può darmi una mano:

    io ho questo menù, semplicissimo, come potete vedere lo costruisco tutto via AS, quindi senza piazzare nulla sullo stage, e devo dire che funziona bene. l'unico problema è la ridondanza del codice, e cioé, per ogni item di menù devo creare una funzione di rollover", io vorrei, invece, crearne solo una che valga per tutti gli item, solo che non ci riesco:

    ho provato con:

    Codice PHP:
    trace("btn"+i);     _root.btn.onRollOver= function() {         var btn_R:Tween = new Tween(_root."btn"+i.txt,"_y",Back.easeOut,0,20,0.6,true);         var btn_RO:Tween = new Tween(_root."btn"+i.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);     }     _root.btn.onRollOut= function() {         var btn_R:Tween = new Tween(_root."btn"+i.txt,"_y",Back.easeOut,20,0,0.6,true);         var btn_RO:Tween = new Tween(_root."btn"+i.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);     } 
    il trace mi da l'output corretto, ma non riesco ad impostare correttamente la tween, qualcuno può darmi una mano?

    Codice PHP:
    //menu function
    function menu(){
        for(var 
    i=0i<6i++){
            
    _root.btn _root.attachMovie("btn""btn"+ii);
            
    _root.btn._y=420;
            
    _root.btn.txt.txt.autoSize=true;
            
    _root.btn.txt_hv.txt_hv.autoSize=true;
            switch (
    item) {
            case 
    _root.btn1 :
                
    _root.btn.txt.txt="filosofia";
                
    _root.btn.txt_hv.txt_hv="filosofia";
                
    _root.btn._x=445;
                
    _root.btn.btn_mask._width=_root.btn._width;
                
    _root.btn.btn_mask._height=20;
                
    _root.btn.btn_hand._width=_root.btn._width;
                
    _root.btn.btn_hand._height=20;
            break;
            case 
    _root.btn2 :
                
    _root.btn.txt.txt="identità";
                
    _root.btn.txt_hv.txt_hv="identità";
                
    _root.btn._x=_root.btn0._x+_root.btn0._width+6;
                
    _root.btn.btn_mask._width=_root.btn._width;
                
    _root.btn.btn_mask._height=20;
                
    _root.btn.btn_hand._width=_root.btn._width;
                
    _root.btn.btn_hand._height=20;
            break;
            case 
    _root.btn3 :
                
    _root.btn.txt.txt="servizi";
                
    _root.btn.txt_hv.txt_hv="servizi";
                
    _root.btn._x=_root.btn1._x+_root.btn1._width+6;
                
    _root.btn.btn_mask._width=_root.btn._width;
                
    _root.btn.btn_mask._height=20;
                
    _root.btn.btn_hand._width=_root.btn._width;
                
    _root.btn.btn_hand._height=20;
            break;
            case 
    _root.btn4 :
                
    _root.btn.txt.txt="portfolio";
                
    _root.btn.txt_hv.txt_hv="portfolio";
                
    _root.btn._x=_root.btn2._x+_root.btn2._width+6;
                
    _root.btn.btn_mask._width=_root.btn._width;
                
    _root.btn.btn_mask._height=20;
                
    _root.btn.btn_hand._width=_root.btn._width;
                
    _root.btn.btn_hand._height=20;
            break;
            case 
    _root.btn5 :
                
    _root.btn.txt.txt="novità";
                
    _root.btn.txt_hv.txt_hv="novità";
                
    _root.btn._x=_root.btn3._x+_root.btn3._width+6;
                
    _root.btn.btn_mask._width=_root.btn._width;
                
    _root.btn.btn_mask._height=20;
                
    _root.btn.btn_hand._width=_root.btn._width;
                
    _root.btn.btn_hand._height=20;
            break;
            case 
    _root.btn6 :
                
    _root.btn.txt.txt="@";
                
    _root.btn.txt_hv.txt_hv="@";
                
    _root.btn._x=_root.btn4._x+_root.btn4._width+6;
                
    _root.btn.btn_mask._width=_root.btn._width;
                
    _root.btn.btn_mask._height=20;
                
    _root.btn.btn_hand._width=_root.btn._width;
                
    _root.btn.btn_hand._height=20;
            break;
            }
        
    /*trace("btn"+i);
        _root.btn.onRollOver= function() {
            var btn_R:Tween = new Tween(_root."btn"+i.txt,"_y",Back.easeOut,0,20,0.6,true);
            var btn_RO:Tween = new Tween(_root."btn"+i.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
        }
        _root.btn.onRollOut= function() {
            var btn_R:Tween = new Tween(_root."btn"+i.txt,"_y",Back.easeOut,20,0,0.6,true);
            var btn_RO:Tween = new Tween(_root."btn"+i.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);
        }*/
        
    }
        
    _root.btn0.onRollOver= function() {
            var 
    btn0_R:Tween = new Tween(btn0.txt,"_y",Back.easeOut,0,20,0.6,true);
            var 
    btn0_RO:Tween = new Tween(btn0.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
        }
        
    _root.btn0.onRollOut= function() {
            var 
    btn0_R:Tween = new Tween(btn0.txt,"_y",Back.easeOut,20,0,0.6,true);
            var 
    btn0_RO:Tween = new Tween(btn0.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);
        }
        
    _root.btn1.onRollOver= function() {
            var 
    btn1_R:Tween = new Tween(btn1.txt,"_y",Back.easeOut,0,20,0.6,true);
            var 
    btn1_RO:Tween = new Tween(btn1.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
        }
        
    _root.btn1.onRollOut= function() {
            var 
    btn1_R:Tween = new Tween(btn1.txt,"_y",Back.easeOut,20,0,0.6,true);
            var 
    btn1_RO:Tween = new Tween(btn1.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);
        }
        
    _root.btn2.onRollOver= function() {
            var 
    btn2_R:Tween = new Tween(btn2.txt,"_y",Back.easeOut,0,20,0.6,true);
            var 
    btn2_RO:Tween = new Tween(btn2.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
        }
        
    _root.btn2.onRollOut= function() {
            var 
    btn2_R:Tween = new Tween(btn2.txt,"_y",Back.easeOut,20,0,0.6,true);
            var 
    btn2_RO:Tween = new Tween(btn2.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);
        }
        
    _root.btn3.onRollOver= function() {
            var 
    btn3_R:Tween = new Tween(btn3.txt,"_y",Back.easeOut,0,20,0.6,true);
            var 
    btn3_RO:Tween = new Tween(btn3.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
        }
        
    _root.btn3.onRollOut= function() {
            var 
    btn3_R:Tween = new Tween(btn3.txt,"_y",Back.easeOut,20,0,0.6,true);
            var 
    btn3_RO:Tween = new Tween(btn3.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);
        }
        
    _root.btn4.onRollOver= function() {
            var 
    btn4_R:Tween = new Tween(btn4.txt,"_y",Back.easeOut,0,20,0.6,true);
            var 
    btn4_RO:Tween = new Tween(btn4.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
        }
        
    _root.btn4.onRollOut= function() {
            var 
    btn4_R:Tween = new Tween(btn4.txt,"_y",Back.easeOut,20,0,0.6,true);
            var 
    btn4_RO:Tween = new Tween(btn4.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);
        }
        
    _root.btn5.onRollOver= function() {
            var 
    btn5_R:Tween = new Tween(btn5.txt,"_y",Back.easeOut,0,20,0.6,true);
            var 
    btn5_RO:Tween = new Tween(btn5.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
        }
        
    _root.btn5.onRollOut= function() {
            var 
    btn5_R:Tween = new Tween(btn5.txt,"_y",Back.easeOut,20,0,0.6,true);
            var 
    btn5_RO:Tween = new Tween(btn5.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);
        }

    Fuck Your Mind Dance your Brain!

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Prova con questo.
    Codice PHP:
    _root.btn.onRollOver= function() {
        
    this.btn_R = new Tween(this.txt,"_y",Back.easeOut,0,20,0.6,true);
        
    this.btn_RO = new Tween(this.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
    }
    _root.btn.onRollOut = function() {
        
    this.btn_R = new Tween(this.txt,"_y",Back.easeOut,20,0,0.6,true);
        
    this.btn_RO = new Tween(this.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);


  3. #3
    ottimo,

    ....perché non ci ho pensato, grazie millissime.

    Fuck Your Mind Dance your Brain!

  4. #4
    sempre riguardo a questo problema di ridondanza:

    vorrei creare uno stato di "active" per questo menù, qualcuno mi sa indicare una strada corretta per la funzione press?

    grazie in anticipo, nuovamente.

    Codice PHP:

    _root
    .btn.onRollOver= function() {
                
    this.btn_R = new Tween(this.txt,"_y",Back.easeOut,0,20,0.6,true);
                
    this.btn_RO = new Tween(this.txt_hv,"_y",Back.easeOut,-20,0,0.6,true);
            }
            
    _root.btn.onRollOut = function() {
                
    this.btn_R = new Tween(this.txt,"_y",Back.easeOut,20,0,0.6,true);
                
    this.btn_RO = new Tween(this.txt_hv,"_y",Back.easeOut,0,-20,0.6,true);
            }
            
    _root.btn.onPress = function() {
                
    this.btn_P = new Tween(this.txt_p,"_alpha",Back.easeOut,0,100,0.6,true);
                
    this.btn_P = new Tween(this.txt_hv,"_alpha",Back.easeOut,100,0,0.6,true);
                
    this.btn_P = new Tween(this.txt,"_alpha",Back.easeOut,100,0,0.6,true);
                }            
            } 
    Fuck Your Mind Dance your Brain!

  5. #5
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Uno dei problemi che ci sono sulle tween è che si incartano se si usano nomi uguali, quindi intanto sarebbe il caso di usare nomi diversi per tween diverse. Poi vedo che i nomi degli oggetti in cui tenti di cambiare l'alpha riportano "txt" in parte del nome, perciò mi viene da pensare che siano campi di testo e, qualora fossero dinamici, puoi gestirne l'alpha solo se i caratteri sono incorporati in quei campi.

  6. #6
    si si, lo so, devo cambiare il nome, ma cmq non si incartano per il momento, il codice è ancora poco, ma cambierò il nome.

    cmq il carattere è incorporato e lo stato di press funziona,

    quello che in realtà mi servirebbe che qualcuno mi indicasse è un procedimento logico che mi consenta, all'abilitare di uno stato press, la disabilitazione di qualsiasi stato press di istanze differenti del MC "btn" all'interno del quale è contenuto il MC "txt" (che non è un campo di testo perché non riesco ad applicare il movimento direttamente al campo di testo ma lo applico al MC che lo contiente).

    non riesco a trovarlo,

    l'unica cosa che riesco ad intuire logicamente è l'inserimento di un indice numerico:
    Codice PHP:

    if (this.activeBtn!=1){
        
    this.btn_R = new Tween(this.txt_p,"_alpha",Back.easeOut,0,100,0.6,true);
        
    this.btn_RO = new Tween(this.txt_hv,"_alpha",Back.easeOut,100,0,0.6,true);
        
    this.btn_nr = new Tween(this.txt,"_alpha",Back.easeOut,100,0,0.6,true);

    ma questo serve solo a non far ripetere l'azione press.

    posso immaginare un soluzione ma attuarla vorrebbe dire scrivere una funzione press per ogni bottone che verifichi quale degli indici active è uguale ad uno e riporti allo stato normale solo quel bottone in particolare.

    non ci sarebbe un modo più facile?

    del tipo basterebbe una verifica su un indice del tipo

    "istanza di btn precedente all'attuale".

    sto girando e rigirando su internet alla ricerca di qualcosa anche in inglese ma non esiste un procedimento unico c'è solo una marea di confusione sull'argomento.

    grazie.

    Fuck Your Mind Dance your Brain!

  7. #7
    allora, modificando la funzione faccio una cosa del genere:

    Codice PHP:
    _root.btn.onPress = function() {
                if (
    this.activeBtn!=1){
                    
    this.btn_R = new Tween(this.txt_p,"_alpha",Back.easeOut,0,100,0.6,true);
                    
    this.btn_RO = new Tween(this.txt_hv,"_alpha",Back.easeOut,100,0,0.6,true);
                    
    this.btn_nr = new Tween(this.txt,"_alpha",Back.easeOut,100,0,0.6,true);
                    
    this.useHandCursor=false;
                }    
            }
            
    _root.btn.onRelease = function() {
                
    this.activeBtn=1;
                if (
    this.activeBtn!=1){
                    
    this.useHandCursor=true;
                }
            } 
    se io inserisco:
    Codice PHP:
    _root.btn1.onPress = function() 
    e
    Codice PHP:
    _root.btn1.onRelease = function() 
    riesco ad agire solo sul singolo pulsante, potrei quindi fare un controllo del tipo:

    Codice PHP:
    if (btn1.activeBtn=1){
    unactive2();
    unactive3();
    unactive4();
    unactive5();
    unactive6();

    dove unactive sono rispettivamente le funzioni che riportano allo stato normale tutti gli altri pulsanti del tipo:

    Codice PHP:

    function unactive2() {
    if (
    btn2.activeBtn!=1){
    btn2.btn_R = new Tween(this.txt_p,"_alpha",Back.easeOut,100,0,0.6,true);
                    
    btn2.btn_RO = new Tween(this.txt_hv,"_alpha",Back.easeOut,0,100,0.6,true);
                    
    btn2.btn_nr = new Tween(this.txt,"_alpha",Back.easeOut,0,100,0.6,true);
                    
    this.useHandCursor=false;
    }

    ma questo crea un qualcosa di pazzesco.
    Fuck Your Mind Dance your Brain!

  8. #8
    nulla, non riesco,

    ho provato una cosa del genere ma non riesco in nessun modo a disabilitare lo stato press, sul bottone precedentemente attivo, anche se a rigor di logica dovrebbe funzionare.

    qualcuno risce a vederci più chiaro, grazie in anticipo.

    Codice PHP:
    _root.btn.onPress = function() {
                if (
    this.activeBtn!=1){
                    
    this.btn_R = new Tween(this.txt_p,"_alpha",Back.easeOut,0,100,0.6,true);
                    
    this.btn_RO = new Tween(this.txt_hv,"_alpha",Back.easeOut,100,0,0.6,true);
                    
    this.btn_nr = new Tween(this.txt,"_alpha",Back.easeOut,100,0,0.6,true);
                    
    this.useHandCursor=false;
                }
                
    unactive0();
                
    unactive1();
                
    unactive2();
                
    unactive3();
                
    unactive4();
                
    unactive5();
            }
            
    _root.btn.onRelease = function() {
                
    unactive();
                
    this.activeBtn=1;
            }
        }
    }
    //button
    function unactive(){
        
    btn0.activeBtn=0;
        
    btn1.activeBtn=0;
        
    btn2.activeBtn=0;
        
    btn3.activeBtn=0;
        
    btn4.activeBtn=0;
        
    btn5.activeBtn=0;
    }
    function 
    unactive0() {
        if (
    _root.btn0.activeBtn=0){
            
    btn0.btn_R = new Tween(btn0.txt_p,"_alpha",Back.easeOut,100,0,0.6,true);
            
    btn0.btn_RO = new Tween(btn0.txt_hv,"_alpha",Back.easeOut,0,100,0.6,true);
            
    btn0.btn_nr = new Tween(btn0.txt,"_alpha",Back.easeOut,0,100,0.6,true);
            
    this.useHandCursor=true;
        }
    }
    function 
    unactive1() {
        if (
    _root.btn1.activeBtn=0){
            
    btn1.btn_R = new Tween(btn1.txt_p,"_alpha",Back.easeOut,100,0,0.6,true);
            
    btn1.btn_RO = new Tween(btn1.txt_hv,"_alpha",Back.easeOut,0,100,0.6,true);
            
    btn1.btn_nr = new Tween(btn1.txt,"_alpha",Back.easeOut,0,100,0.6,true);
            
    this.useHandCursor=true;
        }
    }
    function 
    unactive2() {
        if (
    _root.btn2.activeBtn=0){
            
    btn2.btn_R = new Tween(btn2.txt_p,"_alpha",Back.easeOut,100,0,0.6,true);
            
    btn2.btn_RO = new Tween(btn2.txt_hv,"_alpha",Back.easeOut,0,100,0.6,true);
            
    btn2.btn_nr = new Tween(btn2.txt,"_alpha",Back.easeOut,0,100,0.6,true);
            
    this.useHandCursor=true;
        }
    }
    function 
    unactive3() {
        if (
    _root.btn3.activeBtn=0){
            
    btn3.btn_R = new Tween(btn3.txt_p,"_alpha",Back.easeOut,100,0,0.6,true);
            
    btn3.btn_RO = new Tween(btn3.txt_hv,"_alpha",Back.easeOut,0,100,0.6,true);
            
    btn3.btn_nr = new Tween(btn3.txt,"_alpha",Back.easeOut,0,100,0.6,true);
            
    this.useHandCursor=true;
        }
    }
    function 
    unactive4() {
        if (
    _root.btn4.activeBtn=0){
            
    btn4.btn_R = new Tween(btn4.txt_p,"_alpha",Back.easeOut,100,0,0.6,true);
            
    btn4.btn_RO = new Tween(btn4.txt_hv,"_alpha",Back.easeOut,0,100,0.6,true);
            
    btn4.btn_nr = new Tween(btn4.txt,"_alpha",Back.easeOut,0,100,0.6,true);
            
    this.useHandCursor=true;
        }
    }
    function 
    unactive5() {
        if (
    _root.btn5.activeBtn=0){
            
    btn5.btn_R = new Tween(btn5.txt_p,"_alpha",Back.easeOut,100,0,0.6,true);
            
    btn5.btn_RO = new Tween(btn5.txt_hv,"_alpha",Back.easeOut,0,100,0.6,true);
            
    btn5.btn_nr = new Tween(btn5.txt,"_alpha",Back.easeOut,0,100,0.6,true);
            
    this.useHandCursor=true;
        }

    Fuck Your Mind Dance your Brain!

  9. #9
    mammamia che catasta di codice....
    ma scusa nn sarebbe meglio fare un ciclo ed in quello assegnare le azioni ai tuoi pls invece di scrivere tutti quei casi??


    ad es una cosa del genere....magari usando un array x i nomi dei clip cosi da svincolarci anche da regole su di essi..

    Codice PHP:
    clipmenu=new Array("bthome","btcamere","btcolazione","btsolarium","btstruttura","btvideo","btprezzi","btdove","btlocalita","btcontatti")
    for(
    i=0;i<clipmenu.length;i++){
        
    _root.menu[clipmenu[i]].num=i;
        
    trace(clipmenu[i])
        
    _root.menu[clipmenu[i]].onRollOver=function(){
            
    //azioni
        
    }
        
    _root.menu[clipmenu[i]].onRollOut=function(){
            
    //azioni
        
    }
        
    _root.menu[clipmenu[i]].onRelease=function(){
                
    //azioni
        
    }
        

    la verità non è una meretrice che si getta al collo di chi non la vuole ma anzi essa è dotata di una così altera bellezza che anche chi sacrifica tutto per ottenerla non è sicuro di averla raggiunta !

  10. #10
    se faccio un controllo del genere:

    Codice PHP:
    _root.btn.onRelease = function() {
                
    trace(this._name);
                
    unactive();
                
    this.activeBtn=1;
                
    trace(_root.btn0.activeBtn);
                
    trace(_root.btn1.activeBtn);
                
    trace(_root.btn2.activeBtn);
                
    trace(_root.btn3.activeBtn);
                
    trace(_root.btn4.activeBtn);
                
    trace(_root.btn5.activeBtn);
            } 
    mi viene restituito il valore corretto!

    quello che non capisco è perché, all'azione press, non mi viene riportato allo stato normale il bottone in questione, cioé perché non mi vengono eseguite le funzioni!:

    Codice PHP:

    _root
    .btn.onPress = function() {
                if (
    this.activeBtn!=1){
                    
    this.btn_R = new Tween(this.txt_p,"_alpha",Back.easeOut,0,100,0.6,true);
                    
    this.btn_RO = new Tween(this.txt_hv,"_alpha",Back.easeOut,100,0,0.6,true);
                    
    this.btn_nr = new Tween(this.txt,"_alpha",Back.easeOut,100,0,0.6,true);
                    
    this.useHandCursor=false;
                }
                
    unactive0();
                
    unactive1();
                
    unactive2();
                
    unactive3();
                
    unactive4();
                
    unactive5();
            } 
    Fuck Your Mind Dance your Brain!

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.