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

    menu da orizzontale a verticale

    salve ragazzi potete aiutarmi con questo codice


    è un menu orizzontale io vorrei metterlo in verticale come posso fare?

    Codice PHP:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;

    //create function to add buttons on stage
    function addButtons() {
        
    pushOverX 0;
        for (
    i=0i<obj.buttons.lengthi++) {
            
    btn menu.attachMovie("button""btn"+i, -i, {_x:pushOverXid:i});
            
    btn.t.autoSize "left";
            
    btn.t.text obj.buttons[i].attributes.title;
            
    btn.t.textColor 0xffffff;
            
    btn.back._width btn.t._width;
            
    pushOverX += Math.round(btn._width+bS);
            
    setBtnEvents(btn);
        }
        
    selectFirstBtn();
        var 
    cl:Color = new Color(menu.bar);
        
    cl.setRGB(tROC);
    }

    //create function for buttons events
    function setBtnEvents(btn:MovieClip) {
        
    btn.onRollOver = function() {
            
    btn this;
            
    st obj.buttons[btn.id].attributes.title;
            
    //apply effect to this btn
            
    btn.t.textColor tROC;
            
    typeText(btn.t,st,0,5);
            
    //stop current tween
            
    menu.bar.tweenX.stop();
            
    menu.bar.tweenWidth.stop();
            
    //tween bar
            
    menu.bar.tweenX = new Tween(menu.bar"_x"Strong.easeOutmenu.bar._xbtn._x.6true);
            
    menu.bar.tweenWidth = new Tween(menu.bar"_width"Strong.easeOutmenu.bar._widthbtn.back._width.6true);
            
    //apply effect to pressed btn
            
    pressedBtn.t.textColor 0xffffff;
            
    typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,1);
            
    //play sound
            
    s.start();
        };
        
    btn.onRollOut = function() {
            
    btn this;
            
    st obj.buttons[btn.id].attributes.title;
            
    //apply effect to this btn
            
    btn.t.textColor 0xffffff;
            
    typeText(btn.t,st,0,1);
            
    //stop current tween
            
    menu.bar.tweenX.stop();
            
    menu.bar.tweenWidth.stop();
            
    //tween bar
            
    menu.bar.tweenX = new Tween(menu.bar"_x"Strong.easeOutmenu.bar._xpressedBtn._x.6true);
            
    menu.bar.tweenWidth = new Tween(menu.bar"_width"Strong.easeOutmenu.bar._widthpressedBtn.back._width.6true);
            
    //apply effect to pressed btn
            
    pressedBtn.t.textColor tROC;
            
    typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,5);
            
    //play sound
            
    s.start();
        };
        
    btn.onPress = function() {
            
    pressedBtn.enabled true;
            
    pressedBtn this;
            
    this.enabled false;
            
    //ADD HERE CUSTOM FUNCTION
            
    st  obj.buttons[pressedBtn.id].attributes.title " button is pressed"
            
    demoFunction(st);
        };
    }


    function 
    selectFirstBtn(){
        
    pressedBtn menu.btn0;
        
    pressedBtn.enabled false;
        
    //tween bar
        
    menu.bar.tweenX = new Tween(menu.bar"_x"Strong.easeOutmenu.bar._xpressedBtn._x.6true);
        
    menu.bar.tweenWidth = new Tween(menu.bar"_width"Strong.easeOutmenu.bar._widthpressedBtn.back._width.6true);
        
    //apply effect to this btn
        
    pressedBtn.t.textColor tROC;
        
    typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,5);
    }

    //create typing effect
    function typeText(t:TextFieldfinalString:StringinitRandomStringLength:Numberspeed:Number) {
        var 
    currentLength:Number 0;
        var 
    counter:Number 0;
        
    t._parent.onEnterFrame = function() {
            if (
    currentLength<finalString.length) {
                
    counter++;
                var 
    currentString:String "";
                var 
    randString:String "";
                
    //get random char
                
    for (i=currentLengthi<initRandomStringLengthi++) {
                    
    randString += String.fromCharCode(random(50)+20);
                }
                
    //add char to complete string
                
    for (i=0i<=currentLengthi++) {
                    
    currentString += finalString.charAt(i);
                }
                
    //if counter is equal to speed or the correct char is found add one unit to current length and set counter equal to 0  
                
    if (counter>=speed || randString.charAt(stL) == finalString.charAt(stL)) {
                    
    currentLength++;
                    
    counter 0;
                }
                
                if (
    initRandomStringLength<finalString.length-1) {
                    
    initRandomStringLength++;
                }
                
    t.text currentString+randString;
            } else {
                
    delete t._parent.onEnterFrame;
            }
        };
    }


    //this function is for preview
    function demoFunction(st:String){
        
    demoMC._alpha 100;
        
    demoMC.t.text st;
        
    demoMC.t.textColor tROC;
        
    demoMC.tweenAlpha = new Tween(demoMC"_alpha"Strong.easeIn10001true);
    }



    var 
    tC:Number = new Number();//text color
    var tROC:Number = new Number();//rollover text color
    var bS:Number = new Number();//buttons spacing

    var pressedBtn:MovieClip = new MovieClip();


    //object that contains data from xml
    var obj:Object = new Object();

    //create nex xml object
    var xml:XML = new XML();
    xml.ignoreWhite true;



    //after the xml is loaded, load variables and parse the date to obj
    xml.onLoad = function(succes) {
        if (
    succes) {
            
    tC Number(this.firstChild.attributes.textColor);
            
    tROC Number(this.firstChild.attributes.rolloverColor);
            
    bS Number(this.firstChild.attributes.spacing);
            
    obj.buttons this.firstChild.childNodes;

            
    //function call
            
    addButtons();
        } else {
            
    trace("xml could not load");
        }
    };

    //the path to the xml file
    xml.load("menu.xml"); 

  2. #2
    posta anche l'xml associato

    anche se poi il vero problema sarebbe il fatto di determinare la distanza del pulsanti del menu dato che la larghezza potrebbe cambiare a seconda della lunghezza della voce

    anche se nn ho visto x bene il cod ....
    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 !

  3. #3
    Codice PHP:
    <?xml version="1.0" encoding="UTF-8"?>

    <menu textColor="0x666666" rolloverColor="0xFFCC00" spacing="20">
        
        <item title="home"/>
        <item title="chi siamo"/>
        <item title="servizi"/>
        <item title="richiedi informazioni"/>
        <item title="photo gallery"/>
        <item title="come arrivare"/>
        <item title="contatti"/>

    </menu>
    non riesco a capire neanche sinceramente come dire a un singolo tasto cosa fare quando lo pressi

    Grazie

  4. #4
    Originariamente inviato da Stabiano
    non riesco a capire neanche sinceramente come dire a un singolo tasto cosa fare quando lo pressi

    Grazie
    beh x quello ci sta ...questa

    btn.onPress = function() {
    pressedBtn.enabled = true;
    pressedBtn = this;
    this.enabled = false;
    //ADD HERE CUSTOM FUNCTION qui vai a mettere le tue azioni
    st = obj.buttons[pressedBtn.id].attributes.title + " button is pressed";
    demoFunction(st);
    };

    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 !

  5. #5
    questo già l'avevo visto quindi se uno dei tasti si chiama btn6 e volessi che quando lo clicco ma carica un nuovo filmato esterno tipo con loadMovieNum come dovrei scrivere? io ho provato gia a farlo ma mi dava errore probabilmente sbaglio la sintassi....

  6. #6
    cmq una cosa alla volta...
    x poter mettere il menu in verticale ti absta modificare la funzione addButtons...in questo modo


    Codice PHP:
    function addButtons() { 
        
    pushOverX 0
        for (
    i=0i<obj.buttons.lengthi++) { 
            
    btn menu.attachMovie("button""btn"+i, -i, {_y:pushOverXid:i}); 
            
    btn.t.autoSize "left"
            
    btn.t.text obj.buttons[i].attributes.title
            
    btn.t.textColor 0xffffff
            
    btn.back._height btn.t._height
            
    pushOverX += Math.round(btn._height+bS); 
            
    setBtnEvents(btn); 
        } 
        
    selectFirstBtn(); 
        var 
    cl:Color = new Color(menu.bar); 
        
    cl.setRGB(tROC); 

    x la seconda domanda ...vuoi che quale pls?? faccia cosa??
    anche se volendo potresti mettere cosa fare o il nome del file da richiamare ...anche nel file xml ...ma + complessa la cosa..poi dipende dalle tue conoscenze...

    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 !

  7. #7
    intanto grazie per il primo quesito sul quale mi hai aiutato il quale funziona benissimo.
    Per diminuire la distanza fra i tasti lo faccio da xml giusto?

    Per quanto riguarda il secondo le mie conoscenze non sono proprio grandiose diciamo che me la cavo un pò con cose meno complesse ma sto cercando di imparare il più possibile.
    Mi basta vedere come la sintassi per richiamare poi la qualunque cosa dal tasto

    Grazie mille

  8. #8
    >intanto grazie per il primo quesito sul quale mi hai aiutato il quale funziona benissimo.
    Per diminuire la distanza fra i tasti lo faccio da xml giusto?

    si qua....spacing="5"

    x la seconda ..cosa deve fare alla pressione del tasto?? caricare con loadmovienum un filmato esterno??

    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 !

  9. #9
    si per esempio tipo loadMovieNum ("nomefile"),2) per dire e quello che viene prima che non capisco.
    tutto ciò quando lo presso deve accadere. il nome d'istanza dovrebbe essere btn1 btn2 etc ect sino al 6 se non erro

  10. #10
    beh con una cosa molto spartana...basta fare un controllo sulle voci cliccate ad es

    btn.onPress = function() {
    pressedBtn.enabled = true;
    pressedBtn = this;
    this.enabled = false;
    //ADD HERE CUSTOM FUNCTION
    st = obj.buttons[pressedBtn.id].attributes.title + " button is pressed";
    trace(st)
    //impostiamo un controllo sul titolo
    if(obj.buttons[pressedBtn.id].attributes.title=="chi siamo"){
    trace("carico chi siamo")
    // le azioni che vuoi
    }
    if(obj.buttons[pressedBtn.id].attributes.title=="contatti"){
    trace("contatti")
    //le azioni che vuoi
    }
    demoFunction(st);
    };

    ho scritto solo due controlli ma li dovresti fare x tutti poi dipende da quello che vuoi afre

    ovviamente cosi si perde il senso del file xml esterno....quindi si potrebbe ad es pensare che alla pressione di ogni tasto ci sarebbe un loadmovienum di una sezione anchessa messa nel file xml ..ma bisogna cambiare ..anzi aggiungere un pò di cose nello script
    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 !

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.