# Setting menu items horizontal instead of virtical

**URL:** <https://forum.kirupa.com/t/setting-menu-items-horizontal-instead-of-virtical/126151>\
**Category:** Uncategorized\
**Created:** [October 20, 2004, 8:20pm UTC](https://forum.kirupa.com/t/setting-menu-items-horizontal-instead-of-virtical/126151 "2004-10-20T20:20:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SpyGuy](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@SpyGuy](https://forum.kirupa.com/u/SpyGuy)\
**Post date:** [October 20, 2004, 8:20pm UTC](https://forum.kirupa.com/t/setting-menu-items-horizontal-instead-of-virtical/126151/1 "2004-10-20T20:20:52Z")

</div>

Hello everyone! I’m currently hacking away at this code that i found here on kirupa. I was wonder how to hack this code so that the menu that’s displayed show’s up horzontal in stead of vertical. I’m pretty new to XML and AS, so please be as clear as possible. Also is there a way to include functions in this same code that will display .jpg images when a particular button is pressed?

Thank you all,  
SpyGuy

// 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(0xf4faff);

```

GenerateMenu = function(container, name, x, y, depth, node\_xml) {  
var curr\_node;  
var curr\_item;  
var curr\_menu = container.createEmptyMovieClip(name, depth);  
for (var i=0; i\<node\_xml.childNodes.length; i++) {  
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;  
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;  
if (node\_xml.childNodes\*.nodeName == “menu”){  
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);  
var col = new Color(this.background);  
col.setRGB(0xf4faff);  
};  
}else{  
curr\_item.arrow.\_visible = false;  
curr\_item.onRollOver = curr\_item.onDragOver = function(){  
curr\_menu.submenu\_mc.removeMovieClip();  
var col = new Color(this.background);  
col.setRGB(0xf4faff);  
};  
}

```
	curr_item.onRollOut = curr_item.onDragOut = function(){
		var col = new Color(this.background);
		col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
	};
	curr_item.onRelease = function(){
		Actions[this.action](this.variables);
		CloseSubmenus();
	};
}

```

};

Createmainmenu = function(x, y, depth, menuxml){  
GenerateMenu(this, “mainmenu\_mc”, x, y, depth, menuxml.firstChild);  
mainmenu\_mc.onMouseUp = function(){  
if (mainmenu\_mc.submenu\_mc && !mainmenu\_mc.hitTest(\_root.\_xmouse, \_root.\_ymouse, true)){  
CloseSubmenus();  
}  
};  
};  
CloseSubmenus = function(){  
mainmenu\_mc.submenu\_mc.removeMovieClip();  
};

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);  
};

menuxml = new XML();  
menuxml.ignoreWhite = true;  
menuxml.onLoad = function(ok){  
if (ok){  
Createmainmenu(10, 10, 0, this);  
message\_txt.text = “message area”;  
}else{  
message\_txt.text = “error: XML not successfully loaded”;  
}  
};  
menuxml.load(“menu1.xml”)
