Dynamisk menu med submenuer...igen
Jeg har stadig store problemer med at få menuen til at virke, det er begrænsningen i 9 submenuer som driller mig, jeg har brug for op til 20 submenuer.Jeg har prøvet meget forskelligt mht. koden, men jeg kan ikke få det til at virke.
Er der nogen der vil hjælpe????
Menuen kan ses som en tutorial, og hele .fla filen kan også downloades her:
http://www.actionscript.org/tutorials/intermediate/Dynamic_menu_with_submenus/index.shtml
Her er uddrag af koden:
for (i=1; i<=_root.total; ++i) {
//duplicate movie clip
menuMC.duplicateMovieClip("menuMC"+i, i);
//then position them one under the other
this["menuMC"+i]._y = this["menuMC"+(i-1)]._y+this["menuMC"+(i-1)]._height;
//The next step is to assign a variable to
//each main menu button, so that when it is clicked,
//there is a simple method for identifying the menu item.
this["menuMC"+i].choice = i;
//Finally, track how many levels have been used to
//create the main menu, so that these can be
//added to as the submenus are duplicated.
levelTrack = i;
}
for (i=1; i<=_root.total; ++i) {
//check to see if the item has a submenu
if (_root["subText"+i]>=1) {
name = "stext"+i;
for (n=1; n<=_root["subText"+i]; ++n) {
levelTrack += 1;
subMenuMC.duplicateMovieClip(name+n, levelTrack);
this[name+n]._visible = false;
this[name+n].choice = (i*10) + n;
}
//position first submenu item under parent
this[name+1]._y = this["menuMC"+i]._y+this["menuMC"+i]._height;
//position rest of submenu items
for (n=2; n<=_root["subText"+i]; ++n) {
this[name+n]._y = this[name+(n-1)]._y+this[name+(n-1)]._height;
}
}
}
function resetMenu() {
for (i=1; i<=_root.total; ++i) {
if (_root["subText"+i]>=1) {
name = "stext"+i;
for (n=1; n<=_root["subText"+i]; ++n) {
this[name+n]._visible = false;
}
}
this["menuMC"+i]._y = this["menuMC"+(i-1)]._y+this["menuMC"+(i-1)]._height;
}
}
function submenuShow() {
resetMenu();
//then test to see if the button that has been clicked has a submenu
if (_root["subText"+choice]>=1) {
//if there is a submenu to be displayed then make these menu items visible
name = "stext"+choice;
for (n=1; n<=_root["subText"+choice]; ++n) {
this[name+n]._visible = true;
}
//and position the rest of the main menu item below the submenu
this["menuMC"+(choice+1)]._y = this[name+(n-1)]._y+this[name+(n-1)]._height;
for (i=choice+2; i<=_root.total; ++i) {
this["menuMC"+i]._y = this["menuMC"+(i-1)]._y+this["menuMC"+(i-1)]._height;
}
}
}
