# How can I achieve this?

**URL:** https://forum.kirupa.com/t/how-can-i-achieve-this/82448
**Category:** flash
**Created:** [March 10, 2005, 11:32am UTC](https://forum.kirupa.com/t/how-can-i-achieve-this/82448 "2005-03-10T11:32:34Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ravibhatdon](https://avatars.discourse-cdn.com/v4/letter/r/a4c791/32.png) [@ravibhatdon](https://forum.kirupa.com/u/ravibhatdon)
#### Post date: [March 10, 2005, 11:32am UTC](https://forum.kirupa.com/t/how-can-i-achieve-this/82448/1 "2005-03-10T11:32:34Z")

</div>

Hello all,  
I am creating dynamic menus from xml file and when I mouse onRollOut some of the button do not change.  
I attach flash movie file and xml file so everybody can understand what my problem.  
when I try to click on item2\_sm1 under submenu1,mainmenu1 and when i change my mouse immediately to item\_mm1 under mainmenu1, the submenu1 should change to white instead of pink color.  
**[color=#ff0000][/color]**

**[color=#ff0000][/color]**

**[color=#ff0000]GenerateMenu = function(container, name, x, y, depth, node\_xml,parentText){  
// variable declarations  
var curr\_node;  
var curr\_item;  
var curr\_menu = container.createEmptyMovieClip(name, depth); [/color]**

\*_[color=#ff0000] 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.trackAsMenu = true;  
curr\_node = node\_xml.childNodes_;  
curr\_item.\_x = x-10;  
curr\_item.\_y = 4+y+i\*curr\_item.\_height;  
//if(curr\_node.nodeName==“menu”)  
// {

```
    curr_item.name.text = curr_node.attributes.name; 

 
    curr_item.parent=parentText; 

```

if (node\_xml.childNodes\*.nodeName == “menu”)  
{  
curr\_item.node\_xml = curr\_node;

```
    curr_item.onRollOut = curr_item.onDragOut= function()

```

{  
this.name.textColor=0xffffff;  
//trace(curr\_item);  
};  
curr\_item.onRollOver = curr\_item.onDragOver= function()  
{  
this.name.textColor=0xffffff;

```
    }; 

```

}  
else  
{  
curr\_item.arrow.\_visible = false;  
curr\_item.name.textColor=0xffffff;  
curr\_item.onRollOver = curr\_item.onDragOver= function()  
{  
this.name.textColor=0xffff45;  
}  
curr\_item.onRollOut = curr\_item.onDragOut= function()  
{  
this.name.textColor=0xffffff;  
//trace(curr\_item);  
}  
}  
// item submenu behavior for rollover event  
if (node\_xml.childNodes\*.firstChild.nodeName == “item” && node\_xml.childNodes\*.nodeName==“menu”)  
{  
// open a submenu  
curr\_item.node\_xml = curr\_node;

```
        curr_item.onRollOver = curr_item.onDragOver = function()

```

{  
//main= curr\_item.name.text  
var x=this.\_x+210;  
var y = this.\_y+ this.\_height -25;

```
            var parent=new Array(); 
            var temp=0; 
            for (var m in this)
{ 
                if(this[m].text)
 {                     
                parent[temp++]=this[m]; 
 //main=this[m];
                }             
            }                 
 
            GenerateMenu(curr_menu, "submenu_mc", x, y, 10, this.node_xml,parent);     
            //trace("inide ==submenu and ==main menu") 
            for(j=0;j&lt;this.parent.length;j++){     
                    
                  // trace(this.parent[j].text);  
  main=this.parent[j].text
  
  //this.parent[j].textColor=0xffff45;
  if( sub==main) 
  this.parent[j].textColor=0xffffff;
  else this.parent[j].textColor=0xffff45;
  
            } 
             
             
            // show a hover color                                 
            this.name.textColor=0xffff45;         
             
        }; 
         
    }

```

else if(node\_xml.childNodes\*.firstChild.nodeName == “item” && node\_xml.childNodes\*.nodeName!=“menu”)  
{  
curr\_item.node\_xml = curr\_node;  
curr\_item.onRollOver = curr\_item.onDragOver = function()  
{  
//var x=this.\_x;  
//var y = this.\_y+ this.\_height +10;  
[//this.name.textColor=0xffff45](https://this.name.textColor=0xffff45);  
var parent=new Array();  
var temp=0;  
for (var m in this)  
{  
if(this[m].text)  
{  
parent[temp++]=this[m];  
}  
}

```
        GenerateMenu(curr_menu, "submenu_mc", x, y, 10, this.node_xml,parent); 
         
            for(j=0;j&lt;this.parent.length;j++){     
                    //this.parent[j].textColor=0xffffff;      
                    //trace(this.parent[j].text);  
  sub=this.parent[j].text
  if( sub!=main) 
  this.parent[j].textColor=0xffff45;
  else this.parent[j].textColor=0xffffff;
            } 
             
        // show a hover color             
        this.name.textColor=0xffff45;     
        }; 
    }

```

else if(node\_xml.childNodes\*.nodeName==“menu”)  
{ //item for mainmenu  
curr\_item.node\_xml = curr\_node;  
curr\_item.onRollOver = curr\_item.onDragOver = function(){  
var x=this.\_x+205;  
var y = this.\_y+ this.\_height -30;  
this.name.textColor=0xffff45;

```
        var parent=new Array(); 
            var temp=0; 
            for (var m in this)
{ 
                if(this[m].text)
 {                     
                parent[temp++]=this[m]; 
 
                }             
            } 
             
             
        GenerateMenu(curr_menu, "submenu_mc", x, y, 10, this.node_xml,parent); 
            for(j=0;j&lt;this.parent.length;j++)
{ 
                    this.parent[j].textColor=0xffffff;     
                    //trace(this.parent[j].text); 
  sub= this.parent[j].text;
  if( sub!=main) 
  this.parent[j].textColor=0xffff45;
 
  
            } 
        // show a hover color 
         this.name.textColor=0xffff45;      
        }; 
    }

```

else  
{ //item for submenu  
curr\_item.node\_xml = curr\_node;  
curr\_item.onRollOver = curr\_item.onDragOver = function()  
{  
var x=this.\_x+ this.\_width -10;  
var y = this.\_y;

```
        var parent=new Array(); 
            var temp=0; 
            for (var m in this)
{ 
                if(this[m].text)
 {                     
                parent[temp++]=this[m]; 
 main= this.parent[j].text;
                }             
            }         
         
        for(var m in curr_menu) 
        { 
            //if(m.menuname.text) 
            if(m instanceof MovieClip) 
                trace(m); 
        } 
             
        GenerateMenu(curr_menu, "submenu_mc", x, y, 10, this.node_xml,parent); 
            
for(j=0;j&lt;this.parent.length;j++){             
                         
                    //trace(this.parent[j].text);
  sub=this.parent[j].text
  //trace(this.parent[j]);
  //var s=this.parent[j].text//(this.parent[j].hitTest(_root._xmouse,_root._ymouse,true))
  //trace(f);
  
  if( sub!=main) 
  this.parent[j].textColor=0xffff45;
  //else if(item!=main)
  //this.parent[j].textColor=0xffff45;
  //else if(sub1==main)
  //this.parent[j].textColor=0xffffff;
  else this.parent[j].textColor=0xffffff;
  //if(this.parent[j].text
  
            }             
        // show a hover color 
       this.name.textColor=0xffff45;     
        }; 
    }         
     
         
     
    curr_item.onRelease= function(){ 
        Actions[this.action](this.variables); 
        CloseSubmenus(); 
    }; 
     
     
}//end for loop 

```

}//end function [/color]\*\*

**[color=#ff0000]// 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();  
}  
};  
}; [/color]**

**[color=#ff0000]CloseSubmenus = function(){  
mainmenu\_mc.submenu\_mc.removeMovieClip();  
this.name.textColor=0xffffff;  
}; [/color]**

\*\*[color=#ff0000]  
// 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(0, 0, 0, this); //x,y,depth  
}  
};  
// load first XML menu  
menu\_xml.load(“ablemenu.xml”);

[/color]\*\*
