Visualizzazione dei risultati da 1 a 4 su 4
  1. #1

    menu dinamico orizzontale

    situazione :
    test effettuati :
    risultati ottenuti :

    sto cercando di mettere in piedi un menu orizzontale con 4/5 btn.
    e fin qui....

    code posted by Marcellus Wollas


    codice:
     
    
    VERSIONE 1
    
    //codice: inizializzazione variabili
    
    menu  = 0;
    depth = 0;
    
    // dichiarazione funzioni
    function crea_menu (fontid, fontsize, startx, starty, text_color, background_color)
    {
    
     menu++;
    
     _root["format_id"+menu] = new TextFormat();
     _root["format_id"+menu].color = text_color;
     _root["format_id"+menu].font  = fontid;
     _root["format_id"+menu].size  = fontsize; 
     _root["format_id"+menu].align = "center";
     menu_str = menu.toString();
    
     handler = "id";
     handler = handler.concat(menu_str);
     
    
     _root[handler+"x"] = startx;
     _root[handler+"y"] = starty;
     _root[handler+"b"] = background_color; 
     return(handler);
    
    }
    function crea_voce (nome, link, menuid)
    {
      
     depth++;
     createEmptyMovieClip("sub"+depth+"_"+menuid, depth, _root[menuid+"x"], _root[menuid+"y"], 1, 1);
     _root.submit_mc.createTextField("voce"+depth+"_"+menuid, depth, _root[menuid+"x"], _root[menuid+"y"], 1, 1); 
     
     _root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].text = "       "+nome+"";
     _root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].setTextFormat(_root["format_"+menuid]); 
     _root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].background = true;
     _root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].backgroundColor = _root[menuid+"b"];  
     
     
     _root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].autoSize = "left";
     _root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].bold = true; 
     _root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].selectable = false;
      
     _root[menuid+"x"] += 4 +_root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].textWidth; 
     // Define button handler
     
     _root["sub"+depth+"_"+menuid]._root["voce"+depth+"_"+menuid].onRelease = function ( ) {
      getURL(link, "_self");
     }
     
    }
    
    
    // creazione dinamica del menu
    m1 = crea_menu("_arial", 13, -10, 245, 0x000000, 0xffffff);
    
    
    crea_voce("unoooo","http://www.google.com",m1);
    crea_voce("dueeee","http://www.google.com",m1 );
    crea_voce("treeee","http://www.google.com",m1);
    crea_voce("quattrooooo","http://www.google.com",m1 );
    crea_voce("cinqueeeeeee","http://www.google.com",m1);
    crea_voce("seiiiiiiiiiii","http://www.google.com",m1 );
    
     
    
    stop();
    fantastico... era esattamente quello che mi serviva!!
    mah, ora non riesco ad adattare lo script alle mie esigenze...

    ho provato a modificare il codice inserendo i TextField all'interno di N mc creati dinamicamente...

    codice:
    VERSIONE 2
    
    //codice: inizializzazione variabili
    menu  = 0;
    depth = 0;
    submitid = 0;
    
    /funzione Crea menu dinamico
    function crea_menu_dinamico ()
    // Create clip
    this.createEmptyMovieClip("submit_mc", 99);
       
    // Add text field
    this.submit_mc.createTextField("submit_txt", 1, 0, 0, 50, 20);
    this.submit_mc.submit_txt.text = "Submit";
       
    // Define button handler
    this.submit_mc.onRelease = function ( ) {
      trace("You pressed the submit button.");
    }
    
    
    // dichiarazione funzioni
    function crea_menu (fontid, fontsize, startx, starty, text_color, background_color)
    {
    	menu++;
    
    	_root["format_id"+menu]       = new TextFormat();
    	_root["format_id"+menu].color = text_color;
    	_root["format_id"+menu].font  = fontid;
    	_root["format_id"+menu].size  = fontsize;
    	_root["format_id"+menu].align = "center";
    	menu_str = menu.toString();
    	handler = "id";
    	handler = handler.concat(menu_str);
    	_root[handler+"x"] = startx;
    	_root[handler+"y"] = starty;
    	_root[handler+"b"] = background_color;	
    	return(handler);
    
    };
    function crea_voce (nome, menuid, submitid)
    {
    	depth++;
    	_root.createEmptyMovieClip("submit_mc"+depth+"_"+submitid, depth);
    	
    	_root["submit_mc"+depth+"_"+submitid].createTextField("voce"+depth+"_"+menuid, depth, _root[menuid+"x"], _root[menuid+"y"], 1, 1);
    	
    	_root["submit_mc"+depth+"_"+submitid]._root["voce"+depth+"_"+menuid].text = "       "+nome+"";
    	_root["submit_mc"+depth+"_"+submitid]._root["voce"+depth+"_"+menuid].setTextFormat(_root["format_"+menuid]);
    	_root["submit_mc"+depth+"_"+submitid]._root["voce"+depth+"_"+menuid].background = false;
    	_root["submit_mc"+depth+"_"+submitid]._root["voce"+depth+"_"+menuid].backgroundColor = _root[menuid+"b"];	
    	_root["submit_mc"+depth+"_"+submitid]._root["voce"+depth+"_"+menuid].autoSize = "left";
    	_root["submit_mc"+depth+"_"+submitid]._root["voce"+depth+"_"+menuid].bold = true;
    	_root["submit_mc"+depth+"_"+submitid]._root["voce"+depth+"_"+menuid].selectable = false;
    		
    	_root[menuid+"x"] += 4 + _root["voce"+depth+"_"+menuid].textWidth;
    	// Define button handler
    	_root["voce"+depth+"_"+menuid].onRelease = function ( ) {
    	 trace("You pressed the submit button.");
    	}
    	
    };
    
    
    
    
    // creazione dinamica del menu
    m1 = crea_menu("_arial", 13, -10, 245, 0x000000, 0xffddbb);
    
    crea_voce(_root.menuUno,m1);
    crea_voce(_root.menuDue, m1);
    crea_voce(_root.menuTre, m1);
    crea_voce(_root.menuQuattro, m1);
    
    
    
    
    stop();
    infine riadattato nuovamente...

    codice:
    VERSIONE 3
    
    // inizializzazione variabili
    menu  = 0;
    depth = 0;
    
    // dichiarazione funzioni
    function crea_menu (fontid, fontsize, startx, starty, text_color, background_color)
    {
    	menu++;
    	_root["format_id"+menu]       = new TextFormat();
    	_root["format_id"+menu].color = text_color;
    	_root["format_id"+menu].font  = fontid;
    	_root["format_id"+menu].size  = fontsize;
    	_root["format_id"+menu].align = "center";
    	menu_str = menu.toString();
    	handler = "id";
    	handler = handler.concat(menu_str);
    	_root[handler+"x"] = startx;
    	_root[handler+"y"] = starty;
    	_root[handler+"b"] = background_color;	
    	return(handler);
    };
    function crea_voce (nome, menuid)
    {
    	depth++;
    	path = "sub"+depth+"_"+m1;
    	_root.createEmptyMovieClip(path, depth, _root[m1+"x"], _root[m1+"y"], 1, 1);
    	depth++;
    	eval(path).createTextField("voce"+depth+"_"+menuid, depth, _root[menuid+"x"], _root[menuid+"y"], 1, 1);
    	eval(path)["voce"+depth+"_"+menuid].text = " "+nome+" ";
    	eval(path)["voce"+depth+"_"+menuid].setTextFormat(_root["format_"+menuid]);
    	eval(path)["voce"+depth+"_"+menuid].background = true;
    	eval(path)["voce"+depth+"_"+menuid].backgroundColor = _root[menuid+"b"];	
    	eval(path)["voce"+depth+"_"+menuid].autoSize = "left";
    	eval(path)["voce"+depth+"_"+menuid].selectable = false;
    	_root[menuid+"x"] += 4 + eval(path)["voce"+depth+"_"+menuid].textWidth;
    };
    
    // creazione dinamica del menu
    m1 = crea_menu("_sans", 15, 0, 0, 0x002244, 0xffddbb);
    crea_voce("uno", m1);
    crea_voce("due", m1);
    crea_voce("tre", m1);
    crea_voce("quattro", m1);
    stop();
    ma non capisco come poter far creare i mc uno di seguito all'altro in base alla lungezza del testo.

    please.... non mi abbandonate!!!
    :ortfolio
    http://byn.it
    http://cafemash.it

  2. #2
    ehm.. non ho letto bene il tuo codice, comunque in teoria dovresti fare una cosa tipo:
    codice:
    for (i=0; i<n; i++) {
    	contenitore.attachMovie("clip", "clip"+i, i+100);
    	var path:MovieClip = contenitore["clip"+i];
    	//
    	path.testo.autoSize = true;
    	path.testo._width = 300;
    	path.testo.selectable = false;
    	path.testo.text = _root["iltesto"+i];
    	//
    	var pathPrec:MovieClip = contenitore["clip"+Number(i-1)];
    	path._x = pathPrec._x+pathPrec._width+10;
    }
    dove "contenitore" è il movie che contiene tutto il tuo menu, "clip" è il movie che funge da pulsante e "testo" è il nome di istanza delll'area di testo dinamica..
    vedi un po se funziona..!
    ciaaaao

  3. #3

    ...F a v o l o s o!!

    mi hai curato il mal di testa...

    ?posso chiederti ancora una cosa:

    hai idea perchè le variabili che carico da un txt (es: _layer21.HUNO)

    non riesco a renderizzarle in un for() e devo porca zozza sempre ricadere in 64 righe di codice in più!?!?!

    se hai tempo e voglia...

    Tks a lot


    P.s.
    complimenti per il site!!
    very good
    (anche se c'era da immaginarselo...
    :ortfolio
    http://byn.it
    http://cafemash.it

  4. #4

    ops..

    dimanticavo il CODE...

    codice:
    
    loadVariablesNum("it.txt", 21);
    
    
    //variabili che mi passa PHP
    voiceMenu0 = _root.menuUno;
    voiceMenu1 = _root.menuDue;
    voiceMenu2 = _root.menuTre;
    voiceMenu3 = _root.menuQuattro;
    
    linkMenu0 = _root.LinkMenuUno;
    linkMenu1 = _root.LinkMenuDue;
    linkMenu2 = _root.LinkMenuTre;
    linkMenu3 = _root.LinkMenuQuattro;
    
    var menu:Array=new Array();
    menu=[_level21.HUNO, _level21.HDUE, _level21.HTRE, _level21.HQUATTRO];
    
    vocimenu = 4;
    for (i=0; i<vocimenu; i++) {
    	contenitore.attachMovie("clip", "clip"+i, i+100);
    	var path:MovieClip = contenitore["clip"+i];
    	//
    	path.testo.autoSize = true;
    	path.testo._width = 300; 
    	path.testo.selectable = false;
    	path.testo.text = _root["voiceMenu"+i];
    	//
    	var pathPrec:MovieClip = contenitore["clip"+Number(i-1)];
    
    	path._x = pathPrec._x+pathPrec._width+10;
    	
    	/**********************************
    	
    	Questo IL CODE che NON MI RENDERIZZA LE LABEL!!
    	e che ho dovuto sostituire con il blocco sotto :/
    	
    	_root.contenitore.clip0.onRollOver = function(){
    		_root.NavStep.helpmenu.gotoAndPlay('Hopen');
    		_root.NavStep.helpmenu.Htxt.text = menu[i];
    	}
    	
    	**********************************+/
    	
    	
    	_root.contenitore["clip"+Number(i)].onRollOut = function(){
    		_root.NavStep.helpmenu.gotoAndPlay('Hclose');
    	}
    }
    _root.contenitore.clip0.onRollOver = function(){
    	_root.NavStep.helpmenu.gotoAndPlay('Hopen');
    	_root.NavStep.helpmenu.Htxt.text = _level21.H1;
    }
    _root.contenitore.clip1.onRollOver = function(){
    	_root.NavStep.helpmenu.gotoAndPlay('Hopen');
    	_root.NavStep.helpmenu.Htxt.text = _level21.H2;
    }
    _root.contenitore.clip2.onRollOver = function(){
    	_root.NavStep.helpmenu.gotoAndPlay('Hopen');
    	_root.NavStep.helpmenu.Htxt.text = _level21.H3;
    }
    _root.contenitore.clip3.onRollOver = function(){
    	_root.NavStep.helpmenu.gotoAndPlay('Hopen');
    	_root.NavStep.helpmenu.Htxt.text = _level21.H4;
    }
    
    _root.contenitore.clip1.onRelease = function(){
    		if(_root.page != "1"){
    			_root.NavStep.helpmenu.gotoAndPlay('Hclose');
    			getURL("www.google.com", "_self");
    		}
    	}
    :ortfolio
    http://byn.it
    http://cafemash.it

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.