Hey everybody! I'm new to this forum & I'd like to get some help with a 'flash xml menu with sub menus' that I already have. The problem is that main menu labels are short:
HOME
PORTFOLIO
CONTACT US
ABOUT US
but the sub menus are longer:
Transcend Music Publishing
Allure Flowers etc.
So what happens is the sub menus are cut short. If I increase the dynamic text box size, & bring the sub menu nearer:
curr_item.onRollOver = curr_item.onDragOver = function(){
var x = this._x + this._width +3;
GenerateMenu(curr_menu, "submenu_mc", x, y, 1000, this.node_xml);
// show a hover color
var col = new Color(this.background);
col.setRGB(0xf4faff);
};
the main menu gets activated.
Here's the flash code:
// 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;
// this._x =25
// this._y =125
// x=25
// y=125
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("menuitem2","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[i];
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[i].nodeName == "menu"){
// open a submenu
curr_item.node_xml = curr_node;
curr_item.onRollOver = curr_item.onDragOver = function(){
var x = this._x + this._width +3;
GenerateMenu(curr_menu, "submenu_mc", x, y, 1000, this.node_xml);
// show a hover color
var col = new Color(this.background);
col.setRGB(0xf4faff);
};
}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(0xf4faff);
};
}
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(){
Actions[this.action](this.variables);
CloseSubmenus();
};
} // end for loop
};
// create the main menu, this will be constantly visible
CreateMainMenu = function(x, y, depth, menu_xml){
var x=218
var y=52
// 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);
};
Actions.img = function(img){
loadMovie(img,imgbox);
};
// 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");
and xml code:
<?xml version="1.0"?>
<menu name="Press">
<menu name="LOGOS">
<item name="ALLURE FLOWERS" action="img" variables="images/GalleryPress.jpg"/>
<item name="CANDID MOMENTS" action="img" variables="images/img2.jpg"/>
<item name="COOL-O MINT" action="img" variables="img3.jpg"/>
<item name="CRICKET ACADEMY" action="img" variables=""/>
<item name="EAST-WEST TRAVELS" action="img" variables=""/>
<item name="ECO RESIDENCIES" action="img" variables=""/>
<item name="GET THERE!" action="img" variables=""/>
<item name="GLOBAL DESTINATIONS" action="img" variables=""/>
<item name="GLOBAL DYNAMIC SOU..." action="img" variables=""/>
<item name="GOLDEN OPTICIANS" action="img" variables=""/>
<item name="GO MEDIA" action="img" variables=""/>
<item name="JUMP START" action="img" variables=""/>
<item name="LIFE PHARMACEUTICALS" action="img" variables=""/>
<item name="ONWARD BPO" action="img" variables=""/>
<item name="ORBIT" action="img" variables=""/>
<item name="Q & Q ASSOCIATES" action="img" variables=""/>
<item name="RUFF RIDERS" action="img" variables=""/>
<item name="SELECT" action="img" variables=""/>
<item name="STAR PULSE" action="img" variables=""/>
<item name="TRANSCEND MUSIC PUBL..." action="img" variables=""/>
<item name="TROPICANA BEACH RESORT" action="img" variables=""/>
<item name="WELLNESS SPA" action="img" variables=""/>
<item name="WINGS RESTAURANT" action="img" variables=""/>
</menu>
<menu name="CORPORATE ID">
<item name="ALLURE FLOWERS" action="img" variables="images/GalleryPress.jpg"/>
<item name="EAST-WEST TRAVELS" action="img" variables=""/>
<item name="GET THERE!" action="img" variables=""/>
<item name="JUMP START" action="img" variables=""/>
<item name="Q & Q ASSOCIATES" action="img" variables=""/>
<item name="STAR PULSE" action="img" variables=""/>
</menu>
<menu name="PRESS">
<item name="item a"/>
<item name="item b"/>
<item name="item c"/>
<item name="item d"/>
<item name="item e"/>
</menu>
<menu name="ANIMATION">
<item name="item"/>
<item name="item"/>
<item name="item"/>
</menu>
Thanks in advance!