MenuBar Component Again!

Anyone know how to add event handlers to a Menu on the MenuBar component.

I know how to do it on MenuItems but I also want to be able to do it on the root Menu…

for example

File - root menu
Edit - menuItem
Cut - menuItem
Copy - menuItem

I want to assign an event handler to “File” but I can’t see a way of doing it. On menuItem’s you assign them an instance name so that’s easy but you can’t do that to the root Menu… any ideas?

shrink your footer

sorry?

surely there must be someone who knows the answer!

Man… i shure hope that someone knows!!!.. i’m facing the same problem and i can’t find a solution anywhere… :((((

If i see something i will report… please do the same…

Hi Oliv,

Glad it’s not just me. did some poking around on the Macromedia website and found this…

This was from a post partly to do with our issue, they also had the menuBar gettings it’s menu from XML so I’m ignoring that… anyway the bit I noticed was this…

var menu = evt.menu;
var item = evt.menuItem;

I haven’t yet tried writing this into the code for my listener, perhaps you could it a whirl?

var myMenuData:XML = xmlData.childNodes[0];
mc_MainMenu.dataProvider = myMenuData;
var menuListener = new Object();
menuListener.__owner = this;
menuListener.change = function(evt) {
var menu = evt.menu;
var item = evt.menuItem;
if (item != undefined) {
var selItem:String = item.attributes.instanceName;
var o = this.__owner;
}
};
mc_MainMenu.addEventListener(“change”, menuListener);
// There is no change event on menuBar.
// The change listener must be set on the differents menus.
menuListener.focusIn = function(evt) {
if (this.initChange == undefined) {
this.initChange = true;
var menuObj = evt.target;
var length = menuObj.dataProvider.childNodes.length;
// no access function
for (var i = 0; i<length; i++) {
menuObj.getMenuAt(i).addEventListener(“change”, this);
}
}
};
var menu = evt.menu;

i created a menu bar the other night, now i really don’t think you can do what you originally asked, thts why i didn’t post, but it looks like you need some answers

edit: i said shrink your footer to that person with the rude comment btw not you :wink:

thanks… no probs…

surely there must be a way to do this… wots the point otherwise! lol

if we can’t use the menuBar component what are the alternatives?

I presume you tried the same thing?

have you tried var myvar = evt.menu ?

does this trigger an event that the listener picks up on?

so jobbie78…
i think we really have a problem… i all ready had my code like you posted… so it’s not that…
and as Digitalosophy says i’m starting to think that this is impossible, and that it is one more “merda mal feita” (i say it in portuguese so i don´t ofend no one…) in FlashMX2004…
Still if i get something you will know it!..

one word “pants” lol

so what is everyone else doing then?

:puzzle: