Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    168

    Menu a tendina verticale

    Salve a tutti, ho trovato un tutorial che realizza un menu a tendina con alcune categorie, e categorie con sottomenu. (il tutto prese da un file XML).

    Cosi il file XML:

    <menu>
    <menuItem label="Home" data="home.swf">
    </menuItem>
    <menuItem label="Inserzioni" data="dove.swf">
    </menuItem>
    <menuItem label="Dove Dormire" data="">
    </menuItem>
    <menuItem label="Arte e Cultura">
    <sub label="Chiese e Monumenti" data=""/>
    <sub label="Musei" data=""/>
    <sub label="Ville" data=""/>
    <sub label="Folclore e leggende" data=""/>
    </menuItem>
    </menu>

    ok... ma il problema è... dove in DATA lui carica "dove.swf" o altri swf io dovrei far aprire una pagina con un getURL.

    Il filmato è ad un solo fotogramma e questo lo script...

    this._lockroot = true;

    itemClass.prototype = new MovieClip();
    Object.registerClass("item",itemClass);

    function itemClass(){
    this.open = false;
    itemOpen = undefined;
    }

    itemClass.prototype.init = function(i){
    this.mc = _root.menu.attachMovie("item","item"+i,10*i);
    }

    itemClass.prototype.onEnterFrame = function(){

    if(this.quel() <= itemToOpen){
    this.seek = this.park;
    }else if(this.quel() > itemToOpen){
    this.seek = this.park + distance;
    }else{

    }
    this.goEase(this.seek,4);
    }

    itemClass.prototype.onRollOver = function(){

    if(this.open){
    itemToOpen = undefined;
    itemToClose = this.quel();
    }else{
    itemToOpen = this.quel();
    itemToClose = undefined;
    }
    distance = this.distance ;
    }

    itemClass.prototype.onRollOut = function(){
    itemToOpen = Infinity;
    }

    itemClass.prototype.quel = function(){
    return Number(this._name.slice(4));
    }

    itemClass.prototype.goEase = function(target,speed){
    this._y = this._y + (target - this._y)/speed;
    if(Math.abs(this._y-target) < 0.8)this._y = target;
    }


    ----------------------------

    menuClass.prototype = new MovieClip();
    function menuClass(){
    this = _root.attachMovie("menu","menu",0);
    this._visible = false;
    this._data = new XML();
    this._data._parent = this;
    this._data.ignoreWhite = true;;
    this._data.load("menu.xml");
    this._data.onLoad = parseMenu;
    this.init();
    }

    Object.registerClass("menu",menuClass);

    parseMenu = function(){
    nbChilds = this.firstChild.childNodes.length;
    //for(var i=0;i<nbChilds+1;i++){
    for(var i in this.firstChild.childNodes){
    temp = new itemClass();
    temp.init(i);
    itemMc = temp.mc;
    itemMc._y = 20*i;
    itemMc.park = 20*i;
    itemMc.label = this.firstChild.childNodes[i].attributes.label;

    for(var j=0;j<this.firstChild.childNodes[i].childNodes.length;j++){
    itemMc.attachMovie("sub","sub"+j,10*j);
    itemMc["sub"+j]._y = 20 + 20*j;
    itemMc["sub"+j].toto = this.firstChild.childNodes[i].childNodes[j].attributes.label;
    }
    itemMc.distance = j*20;
    }
    var temp = new itemClass();
    temp.init(this.firstChild.childNodes.length);
    var itemMc = temp.mc;
    itemMc._y = 20*this.firstChild.childNodes.length;
    itemMc.park = 20*this.firstChild.childNodes.length;

    this._parent._visible = true;
    }

    menuClass.prototype.init = function(){
    this.attachMovie("mask","mask",300);
    with(this.mask){
    _y = -1
    _height = _root.menu.item4._y;
    _width = 146;
    }

    this.createEmptyMovieClip("topEdge",203);
    with(this.topEdge){
    lineStyle( 0.25, 0x000000, 100 );
    moveTo( 0,0);
    lineTo(146,0);
    }
    this.setMask(this.mask)
    }

    menuClass.prototype.onEnterFrame = function(){

    this.mask._height = this.item4._y+2;

    this.createEmptyMovieClip("leftEdge",200);
    with(this.leftEdge){
    lineStyle( 0.25, 0x000000, 100 );
    moveTo( 0, 0 );
    lineTo( 0,this.item4._y );
    }

    this.createEmptyMovieClip("rightEdge",201);
    with(this.rightEdge){
    lineStyle( 0.25, 0x000000, 100 );
    moveTo( 145, 0 );
    lineTo( 145,this.item4._y );
    }

    this.createEmptyMovieClip("bottomEdge",202);
    with(this.bottomEdge){
    lineStyle( 0.25, 0x000000, 100 );
    moveTo( 0,this.item4._y );
    lineTo( 145, this.item4._y);
    }
    }

    myMenu = new menuClass();


    dove modificare??? Grazie un milione...

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    168

    nessuna risposta???

    vi pregooooo è importantissimo!!

  3. #3
    Per un menù a tendina mi sembra veramente un'esagerazione di codice.

    cerca qualcosa di più semplice direttamente in Movie del sito
    flash-mx.html.it

    Ciao

  4. #4

    Re: nessuna risposta???

    Originariamente inviato da Lara78
    vi pregooooo è importantissimo!!
    A parte che quando mettete queste cose che poi nemmeno sono vostre mi fate venire l'acidità di stomaco, anche perché poi non vi si possono nemmeno chiedere chiartimenti, dato che non è codice vostro e non sapete dove mettere le mani...

    Così di primo impatto mi sa che devi aggiungere qualcosa del genere qui:

    codice:
    parseMenu = function(){ 
    	nbChilds = this.firstChild.childNodes.length; 
    //for(var i=0;i<nbChilds+1;i++){ 
    	for(var i in this.firstChild.childNodes){ 
    		temp = new itemClass(); 
    		temp.init(i); 
    		itemMc = temp.mc; 
    		itemMc._y = 20*i; 
    		itemMc.park = 20*i; 
    		itemMc.label = this.firstChild.childNodes[i].attributes.label;
                    // ovviamente qui dovrai fargli prendere il valore del link dall'XML, io ora, per comodità, ho usato semplicemente il valore dell'etichetta della sezione
    		itemMc.link = this.firstChild.childNodes[i].attributes.label;
    		itemMc.onPress = function(){
    			trace(this.link);
    		}; 	
    		
    		for(var j=0;j<this.firstChild.childNodes[i].childNodes.length;j++){ 
    			itemMc.attachMovie("sub","sub"+j,1000*j); 
    			itemMc["sub"+j]._y = 20 + 20*j; 
    			itemMc["sub"+j].toto = this.firstChild.childNodes[i].childNodes[j].attributes.label;
    			// idem con patate come sopra
                            itemMc["sub"+j].link = this.firstChild.childNodes[i].childNodes[j].attributes.label;
    			itemMc["sub"+j].label.text = itemMc["sub"+j].link;
    			//trace(this.firstChild.childNodes[i].childNodes[j].attributes.label);
    			itemMc["sub"+j].onPress = function(){
    				trace(this.link);
    			};
    		}
    Testandolo però ho riscontrato che qualcosa mi copre i pulsanti di ogni submenu, quindi non mi viene rilevato il rispettivo evento onPress ma mi viene sempre eseguito quello del pulsante della voce principale selezionata. Probabilmente è solo un problema dovuto a qualche casino a livello di struttura che ho fatto io tentando di simulare il tuo menu, probabilmente da te non si presenterà questo inconveniente.

  5. #5
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    168

    Chiedo scusa x l'acidità di stomaco provocata....

    Ma essendo newbye ho cercato risorse cercando di capire...

    cmq... ho provato ma nn mi va...

    grazie lo stesso...

    ancora scusa x l'acidità....

  6. #6

  7. #7

    Re: Chiedo scusa x l'acidità di stomaco provocata....

    Originariamente inviato da Lara78
    Ma essendo newbye ho cercato risorse cercando di capire...

    cmq... ho provato ma nn mi va...

    grazie lo stesso...

    ancora scusa x l'acidità....

    Ovviamente era una battuta, in ogni caso bisogna vedere come hai implementato quanto ti ho detto, forse sul movie originale (quello da cui hai estrapolato il codice) facendo quelle semplici modifiche funziona, ovviamente devi anche aggiornare l'XML.

    Comunque vedi se quelli che ti hanno suggerito funzionano.

    Al fin della fiera, comunque, quel menu che hai postato è molto interessante e abbastanza potente.

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.