# Menu Help

**URL:** <https://forum.kirupa.com/t/menu-help/176734>\
**Category:** Uncategorized\
**Created:** [January 26, 2006, 2:00pm UTC](https://forum.kirupa.com/t/menu-help/176734 "2006-01-26T14:00:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Still\_Learning](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@Still\_Learning](https://forum.kirupa.com/u/Still_Learning)\
**Post date:** [January 26, 2006, 2:00pm UTC](https://forum.kirupa.com/t/menu-help/176734/1 "2006-01-26T14:00:26Z")

</div>

OK, I’m now desperate…

After reading the XML drop-down menu tutorial on this site I’ve constructed the very basics of my menu. I’ve spend countless hours trying to figure out how to change the alignment of this menu to go to “horizonal” i.e. the main menu buttons must lie horizontally with the sub-menu’s opening up directly beneath them in a vertical fashion. Sub-sub menu’s obviously lie adjacent to the sub-menu in question.

Please help!!!

PS. Also, how do I get rid of the spacing between the buttons?

Current coding:

// generates a list of menu items (effectively one menu)  
// given the inputted parameters. This makes the main menu  
// as well as any of the submenus  
GenerateMenu = function(container, name, x, y, depth, node\_xml) {  
// variable declarations  
var curr\_node;  
var curr\_item;  
var curr\_menu = container.createEmptyMovieClip(name, depth);

// for all items or XML nodes (items and menus)  
// within this node\_xml passed for this menu  
for (var i=0; i\<node\_xml.childNodes.length; i++) {  
// movieclip for each menu item  
curr\_item = curr\_menu.attachMovie(“menuitem”,“item”+i+"\_mc", i);  
curr\_item.\_x = x;  
curr\_item.\_y = y + i\*curr\_item.\_height;  
curr\_item.trackAsMenu = true;

// item properties assigned from XML  
curr\_node = node\_xml.childNodes\*;  
curr\_item.action = curr\_node.attributes.action;  
curr\_item.variables = curr\_node.attributes.variables;  
curr\_item.name.text = curr\_node.attributes.name;

// item submenu behavior for rollover event  
if (node\_xml.childNodes\*.nodeName == “menu”){  
// open a submenu  
curr\_item.node\_xml = curr\_node;  
curr\_item.onRollOver = curr\_item.onDragOver = function(){  
var x = this.\_x + this.\_width - 5;  
var y = this.\_y + 5;  
GenerateMenu(curr\_menu, “submenu\_mc”, x, y, 1000, this.node\_xml);  
// show a hover color  
var col = new Color(this.background);  
col.setRGB(0xffa520);  
};  
}else{ // nodeName == “item”  
curr\_item.arrow.\_visible = false;  
// close existing submenu  
curr\_item.onRollOver = curr\_item.onDragOver = function(){  
curr\_menu.submenu\_mc.removeMovieClip();  
// show a hover color  
var col = new Color(this.background);  
col.setRGB(0xffa520);  
};  
}

curr\_item.onRollOut = curr\_item.onDragOut = function(){  
// restore color  
var col = new Color(this.background);  
col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});  
};

// any item, menu opening or not can have actions  
curr\_item.onRelease = function(){  
Actionsthis.action;  
CloseSubmenus();  
};  
} // end for loop  
};  
// create the main menu, this will be constantly visible  
CreateMainMenu = function(x, y, depth, menu\_xml){  
// generate a menu list  
GenerateMenu(this, “mainmenu\_mc”, x, y, depth, menu\_xml.firstChild);  
// close only submenus if visible durring a mouseup  
// this main menu (mainmenu\_mc) will remain  
mainmenu\_mc.onMouseUp = function(){  
if (mainmenu\_mc.submenu\_mc && !mainmenu\_mc.hitTest(\_root.\_xmouse, \_root.\_ymouse, true)){  
CloseSubmenus();  
}  
};  
};  
// closes all submenus by removing the submenu\_mc  
// in the main menu (if it exists)  
CloseSubmenus = function(){  
mainmenu\_mc.submenu\_mc.removeMovieClip();  
};  
// This actions object handles methods for actions  
// defined by the XML called when a menu item is pressed  
Actions = Object();  
Actions.gotoURL = function(urlVar){  
getURL(urlVar, “\_blank”);  
};  
Actions.message = function(msg){  
message\_txt.text = msg;  
};  
Actions.newMenu = function(menuxml){  
menu\_xml.load(menuxml);  
};  
// load XML, when done, run CreateMainMenu to interpret it  
menu\_xml = new XML();  
menu\_xml.ignoreWhite = true;  
menu\_xml.onLoad = function(ok){  
// create main menu after successful loading of XML  
if (ok){  
CreateMainMenu(10, 10, 0, this);  
message\_txt.text = “message area”;  
}else{  
message\_txt.text = “error: XML not successfully loaded”;  
}  
};  
// load first XML menu  
menu\_xml.load(“menu1.xml”);
