# XML Menu that performs multitasks

**URL:** <https://forum.kirupa.com/t/xml-menu-that-performs-multitasks/214364>\
**Category:** flash\
**Created:** [January 28, 2007, 12:55am UTC](https://forum.kirupa.com/t/xml-menu-that-performs-multitasks/214364 "2007-01-28T00:55:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pherank](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@Pherank](https://forum.kirupa.com/u/Pherank)\
**Post date:** [January 28, 2007, 12:55am UTC](https://forum.kirupa.com/t/xml-menu-that-performs-multitasks/214364/1 "2007-01-28T00:55:56Z")

</div>

I see lots of XML menus that perform one type of action, e.g.: open a new URL everytime a menu item is clicked, but I haven’t seen a good example of how to allow for different actions for different menu buttons. In my case I need to load mainly CDATA test with the exception that one menu item will load an image gallery. I could either call a function to create the gallery or I could use loadMovie to import an external SWF. The main problem is how to change the code below so that when

```auto
items*.attributes.type == "imageGallery"

```

I can do something other than assign the text childNode.

```auto

function CreateMenu(menu_xml){

    var items = menu_xml.firstChild.firstChild.childNodes; // menu -> menuitems -> child nodes array
    for (var i=0; i<items.length; i++) {

        if (items*.attributes.type == "textDisplay") { 
            // create variables for our elements
            var navlabel = items*.firstChild;
            var content = items*.childNodes[1];
        } 
        if (items*.attributes.type == "imageGallery") {
            var navlabel = items*.firstChild; 
            //var content = items*.childNodes[1];
            //NEED TO CALL A FUNCTION HERE
        }
            
            var item_mc = menu_mc.attachMovie("menu_item","item"+item_count, item_count);
            item_mc._y = item_count * item_spacing;
            item_count++;
            
            item_mc.menu_txt.text = navlabel.firstChild.nodeValue;
            item_mc.content_text = content.firstChild.nodeValue;

            // Apply font attributes
            item_mc.menu_txt.embedFonts = true;
            item_mc.menu_txt.setTextFormat(mainNavText);

            // Problem using "DisplayInfo()" syntax or placing within onRelease function
            //item_mc.main_btn.onRelease = DisplayInfo;
            item_mc.onPress = DisplayInfo;
            item_mc.onRelease = function() {
            activebtn.menu_txt.textColor = default_color;

            // Change selected MC text to selected color
            this.menu_txt.textColor = selected_color;
            activebtn = this;
            };
            item_mc.onRollOver = function() {
                if (this != activebtn) {
                    this.menu_txt.textColor = rollover_color;
                }
            };
            item_mc.onRollOut = function() {
                if (this != activebtn) {
                    this.menu_txt.textColor = default_color;
                }
            };
        }
    }

```
