Skip to main content
Participant
June 5, 2006
Question

Problem with the menu bar component

  • June 5, 2006
  • 1 reply
  • 136 views
I have created an application that has a menu bar on it.
It uses this code to be created:

stop();


import mx.controls.Menu;
import mx.controls.MenuBar;

var my_mb:MenuBar;

var my_menu:Menu = my_mb.addMenu("Menu");
my_menu.addMenuItem({label:"File", instanceName:"File"});
my_menu.addMenuItem({label:"Open", instanceName:"Open"});
my_menu.addMenuItem({label:"Settings", instanceName:"Settings"});

//Create listener object.
var mbListenerbject = new Object();
mbListener.change = function(evt_objbject) {
var menuItem_objbject = evt_obj.menuItem;
switch (menuItem_obj.attributes.instanceName) {
case "About":
trace("Open menu item");

break;
case "Services":
trace("Open menu item");
break;
case "Settings":
trace("Close menu item");
break;
}
trace(menuItem_obj);
};

//Add listener.
my_menu.addEventListener("change", mbListener);

Does anybody know how to put actions to the sub menu buttons?

Example - Click here

Jak -Cheers if you can help!
This topic has been closed for replies.

1 reply

Inspiring
August 10, 2006
You can attach the Listener directly to all menus (main or sub). Then your evtObj will always reference the menu changed. This will cut out having to trace back through the menuBar first.