# MenuBar Component

**URL:** <https://forum.kirupa.com/t/menubar-component/45367>\
**Category:** flash\
**Created:** [March 13, 2004, 6:46pm UTC](https://forum.kirupa.com/t/menubar-component/45367 "2004-03-13T18:46:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobbie78](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jobbie78](https://forum.kirupa.com/u/jobbie78)\
**Post date:** [March 13, 2004, 6:46pm UTC](https://forum.kirupa.com/t/menubar-component/45367/1 "2004-03-13T18:46:28Z")

</div>

How do I add an instance name to a Menu?

newsMenu = myMenuBar.addMenu(“News”);  
multiMediaMenu = myMenuBar.addMenu(“Multimedia”);  
multiMediaMenu.addMenuItem({label:“Music”, instanceName:“mnuMusic”});  
multiMediaMenu.addMenuItem({label:“Video”, instanceName:“mnuVideo”});

so in the above code I want to an instance name to be attached to “News”. As above you can do it with menu items but can you do it with the actual menu?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 13, 2004, 7:02pm UTC](https://forum.kirupa.com/t/menubar-component/45367/2 "2004-03-13T19:02:19Z")

</div>

don’t think so… your assigning the variable newsMenu to your menu.

you can cut out a line of code by saying

```auto

var helpMenu = myMenuBar.addMenu("help");
helpMenu.addMenuItem({label:"About", instanceName:"aboutMenuItem"});
helpMenu.addMenuItem({label:"about Digitalosophy", instanceName:"aboutDigital"});

```

why do you need to assign an instance name?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 13, 2004, 7:16pm UTC](https://forum.kirupa.com/t/menubar-component/45367/3 "2004-03-13T19:16:22Z")

</div>

Hey,

In this code the listener responds only for menuItems. But I also want it to respond to Menu buttons…

ie…

In the MenuBar component I have a Menu called News with no MenuItems. I also have another Menu called Multimedia with two menuItems, Music and Video.

How do you get an event response by just clicking on News if it has no instance name?

Hope this makes sense.

var homeMenuListener = new Object();  
homeMenuListener.change = function(eventData) {  
var clickedMenu = eventData.menu;  
var clickedMenuItem = eventData.menuItem;  
switch (clickedMenuItem) {  
case clickedMenu.mnuMusic :  
tickertar.loadMovie(“ticker.swf”);  
break;  
case clickedMenu.mnuVideo :  
trace (“You clicked on the video menu”);  
break;  
}  
}  
multiMediaMenu.addEventListener(“change”, homeMenuListener);  
newsMenu.addEventListener(“change”, homeMenuListener);
