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
![]()
fantastico... era esattamente quello che mi serviva!!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();
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...
infine riadattato nuovamente...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();
ma non capisco come poter far creare i mc uno di seguito all'altro in base alla lungezza del testo.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();
please.... non mi abbandonate!!!![]()


ortfolio
Rispondi quotando
