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<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;
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<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<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<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]**