XML drop-down menu tutorial

I am using the drop-down menu tutorial I found on tihs site and love it! However, I am trying to add a little tweak in here so that when the user rolls out of the submenu or the main menu, it disappears. May seem a bit out, but in the context of the bigger project, which I won’t explain here, this makes sense.

The problem is that I can’t have another rollout event for the entire menu as it conflicts with the submenu rollouts. If that makes any sense.

Here is the script I have now:

// 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);
 var menuBackground = container.createEmptyMovieClip(name, depth);
 var menuHeight;
 // 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+1);
  curr_item._x = x;
  curr_item._y = y + i*curr_item._height;
  curr_item.trackAsMenu = true;
  //measure height of main menu
  menuHeight = curr_item._height*numofitems+16;
  // 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;
  curr_item.linkDescription.text = curr_node.attributes.linkDescription;
  // 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;
    var y = this._y + 8;
    GenerateMenu(curr_menu, "submenu_mc", x, y, 1000, this.node_xml);
    // show a hover color
    var col = new Color(this.background);
  }else{ // nodeName == "item"
   curr_item.arrow._visible = false;
   // close existing submenu
   curr_item.onRollOver = curr_item.onDragOver = function(){
    // show a hover color
    var col = new Color(this.background);
  curr_item.onRollOut = curr_item.onDragOut = function(){
   // restore color
   var col = new Color(this.background);
  // any item, menu opening or not can have actions
  curr_item.onRelease = function(){
  /*menuBackground.onRollOut = function(){
   if(!mainmenu_mc.submenu_mc.hitTest(_root._xmouse, _root._ymouse, true)){
 } // end for loop
 currMenuBackground = menuBackground.attachMovie("background","background", 0);
 currMenuBackground._x = x;
 currMenuBackground._y = y - 8;
 currMenuBackground._yscale = menuHeight;
// 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)){
 mainmenu_mc.onRollOut = function(){
  if(!mainmenu_mc.submenu_mc.hitTest(_root._xmouse, _root._ymouse, true)){
// closes all submenus by removing the submenu_mc
// in the main menu (if it exists)
CloseSubmenus = function(){
//closes the main menu by removing the movie clip
CloseMainMenu = function(){
// 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";
  message_txt.text = "error:  XML not successfully loaded";
// load first XML menu