# Changing font color for Senocular's XML Menu

**URL:** <https://forum.kirupa.com/t/changing-font-color-for-senoculars-xml-menu/223828>\
**Category:** flash\
**Created:** [April 26, 2007, 2:41am UTC](https://forum.kirupa.com/t/changing-font-color-for-senoculars-xml-menu/223828 "2007-04-26T02:41:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kpk9](https://avatars.discourse-cdn.com/v4/letter/k/6a8cbe/32.png) [@kpk9](https://forum.kirupa.com/u/kpk9)\
**Post date:** [April 26, 2007, 2:41am UTC](https://forum.kirupa.com/t/changing-font-color-for-senoculars-xml-menu/223828/1 "2007-04-26T02:41:15Z")

</div>

Dear Friends,

I am going through Senocular’s beautiful tutorial on xml driver drill down menu and was trying to change the the font color with rollover effects. I have a function that I can use for this, but I am not able to call it appropriately from the main program. Please please through some light on this. Thank you.

Senocular’s original 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;  
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&lt;node_xml.childNodes.length; i++) {
    // movieclip for each menu item
    curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
    curr_item._x = x;
    curr_item._y = y + i*curr_item._height;
    curr_item.trackAsMenu = true;
    //tracing curr_item
    trace(curr_item);
    //curr_item.initNewBtn(curr_item);
    // 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;
    var c = curr_node.attributes.name;
        
    // item submenu behavior for rollover event
    if (node_xml.childNodes*.nodeName == "menu"){
        // open a submenu
        curr_item.node_xml = curr_node;
        //changing font color
        
        
        curr_item.name.textColor = 0xff6600;
        curr_item.onRollOver = curr_item.onDragOver = function(){
            
            var x = this._x + this._width + 60;
            //var y = this._y + 0;
            var y = 10;
            GenerateMenu(curr_menu, "submenu_mc", x, y, 1000, this.node_xml);
            // show a hover color
            var col = new Color(this.background);
            col.setRGB(0x666666);
            //curr_item.name.textColor = 0xff6600;
            
            
        };
    }else{ // nodeName == "item"
        curr_item.arrow._visible = false;
        //changing font color
        curr_item.name.textColor = 0xff6600;
        // close existing submenu
        curr_item.onRollOver = curr_item.onDragOver = function(){
            curr_menu.submenu_mc.removeMovieClip();
            //curr_item.name.textColor = 0xff6600;
            // show a hover color
            var col = new Color(this.background);
            col.setRGB(0x666666);
            //curr_item.name.textColor = 0xff6600;
        };
    }
    
    curr_item.onRollOut = curr_item.onDragOut = function(){
        // restore color
        //curr_item.name.textColor = 0xff0000;
        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();
        //curr_item.name.textColor = 0xff66cc;
    };
} // end for loop

```

};

// 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();  
}  
};  
};

// 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);  
};

// 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”);

* * *

Here is the function that I am trying to use:

* * *

function initNewBtn(me) {  
me.onRollOver = function() {  
setColor(me, “rollover”);  
showResources(me);  
};  
me.onRollOut = function() {  
setColor(me, “rollout”);  
};  
me.onPress = function() {  
setColor(me, “pressed”);  
};  
me.onRelease = function() {  
setColor(me, “released”);  
};  
}  
//  
function setColor(myBtn, btnstate) {  
if (btnstate == “rollover”) {  
var colorChange = new Color(myBtn);  
colorChange.setRGB(0xff9933);  
} else if (btnstate == “rollout”) {  
var colorChange = new Color(myBtn);  
colorChange.setRGB(0x00299A);  
} else if (btnstate == “pressed”) {  
var colorChange = new Color(myBtn);  
colorChange.setRGB(0xff3333);  
} else {  
var colorChange = new Color(myBtn);  
colorChange.setRGB(0x00299A);  
}  
}

* * *
