MenuBar.setMenuEnabledAt()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

menuBarInstance.setMenuEnabledAt(index, boolean)

Parameters

index The index of the menu item to set in the MenuBar instance.

boolean A Boolean value indicating whether the menu item at the specified index is enabled (true) or not (false).

Returns

Nothing.

Description

Method; enables the menu at the specified index. If there is no menu at that index, calling this method has no effect.

Example

The following example adds a File menu to the menu bar and calls the setMenuEnabledAt() method to enable or disable the menu, depending on whether the menuEnabled_ch check box is selected or clear.

Drag an instance of the MenuBar component onto the Stage, and enter the instance name my_mb in the Property inspector. Drag a CheckBox component to the Stage and give it an instance name of menuEnabled_ch. Add the following code to Frame 1 of the timeline:

/**
 Requires:
  - MenuBar component on Stage (instance name: my_mb)
  - CheckBox component on Stage (instance name: menuEnabled_ch)
*/

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

var my_mb:MenuBar;
var menuEnabled_ch:CheckBox;

menuEnabled_ch.selected = true;
var my_menu:Menu = my_mb.addMenu("File");
my_menu.addMenuItem({label:"New", instanceName:"newInstance"});
my_menu.addMenuItem({label:"Open", instanceName:"openInstance"});

var chListener:Object = new Object();
chListener.click = function(evt_obj:Object) {
 // Toggle "file" menu.
my_mb.setMenuEnabledAt(0, evt_obj.target.selected);
}
menuEnabled_ch.addEventListener("click", chListener);