I’m trying to create a drop down menu similar to this
http://www.kirupa.com/developer/actionscript/xml_dropdown_menu.htm
but instead of a vertical menu, i want to create a menu that is horizontal.
when i try this, I cant get the submenu to be in the center. please see the attached image.
any ideas?
thanks
Wraj.
==============SOURCE START=====================
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok)
{
if(ok)
{
trace(“XML file loaded”);
Createmainmenu(0,0,0,this);
}
};
menu_xml.load(“menu.xml”);
//function that create the menu using the generate menu function
Createmainmenu = function(x,y,depth,menu_xml)
{
GenerateMenu(this,“mainmenu_mc”,x,y,depth,menu_xml.firstChild); //generate a menu
mainmenu_mc.onMouseUp = function()
{
if(mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root.xouse, _rot.ymouse, true))
{
CloseSubmenus();
}
};
};
//remove submenus.
CloseSubmenus = function()
{
mainmenu_mc.submenu_mc.removeMovieClip();
};
//function that generates a menu iteratively
GenerateMenu = function(container, name, x, y, depth, xml_node)
{
trace(“generate Menu called”);
var curr_node;
var curr_item;
var curr_menu = container.createEmptyMovieClip(name,depth);
//loop through to attach menuitem clips
for(var i=0; i<xml_node.childNodes.length; i++)
{
trace("attaching clip "+i);
curr_item = curr_menu.attachMovie("menuitem","menu_item"+i,depth+i);
curr_item._y = y;
curr_item._x = x + i*curr_item._width;
curr_item.trackAsMenu = true;
curr_menu._x = (Stage.width/2) - (((i+1)*150)/2); //CENTERING SUBMENUS
//insert attributes into the menu item
curr_node = xml_node.childNodes*;
curr_item.button_text.text = curr_node.attributes.name;
if(xml_node.childNodes*.nodeName == "menu")
{
curr_item.xml_node = curr_node;
curr_item.onRollOver = curr_item.onDragOver = function()
{
var y = this._y + 25;
GenerateMenu(curr_menu,"submenu_mc",x,y,1000,this.xml_node);
}
}
else
{
curr_item.arrow._visible = false;
curr_item.onRollOver = curr_item.onRollOver = curr_item.onDragOver = function()
{
curr_menu.submen_mc.removeMovieClip();
}
}
}
};
//button actions
Actions = Object();
Actions.gotoURL = function(urlVar)
{
getURL(urlVar,"_blank");
};
Actions.newTab = function()
{
//create a new tab for second level menu
}
=====================SOURCE END ==============