ActionScript 2.0 Components Language Reference |
|
|
|
| MenuBar component > MenuBar.removeMenuAt() | |||
Flash Player 6 (6.0.79.0).
Flash MX Professional 2004.
menuBarInstance.removeMenuAt(index)
index The index of the menu to be removed from the menu bar.
A reference to the menu at the specified index in the menu bar. This value is undefined if there is no menu in that position in the menu bar.
Method; removes the menu at the specified index. If there is no menu item at that index, calling this method has no effect. Also, when more than one menu is removed, the index assignments shift accordingly as each menu is removed.
The following example creates a File menu and an Edit menu on the menu bar. It then calls removeMenuAt() to remove the menu at position 0, which is the File menu, leaving the Edit menu.
Drag an instance of the MenuBar component onto the Stage, and enter the instance name my_mb in the Property inspector. Add the following code to Frame 1 of the timeline:
/**
Requires:
- MenuBar component on Stage (instance name: my_mb)
*/
import mx.controls.Menu;
import mx.controls.MenuBar;
var my_mb:MenuBar;
var file_menu:Menu = my_mb.addMenu("File");
file_menu.addMenuItem({label:"New", instanceName:"newInstance"});
file_menu.addMenuItem({label:"Open", instanceName:"openInstance"});
var edit_menu:Menu = my_mb.addMenu("Edit");
edit_menu.addMenuItem({label:"Cut", instanceName:"cutInstance"});
edit_menu.addMenuItem({label:"Copy", instanceName:"copyInstance"});
edit_menu.addMenuItem({label:"Paste", instanceName:"pasteInstance"});
//Delete "file" menu.
my_mb.removeMenuAt(0);
|
|
|
|