MenuBar.getMenuAt()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX Professional 2004.

Usage

menuBarInstance.getMenuAt(index)

Parameters

index An integer indicating the position of the menu.

Returns

A reference to the menu at the specified index. This value is undefined if there is no menu at that position.

Description

Method; returns a reference to the menu at the specified index. Because getMenuAt() returns a reference, it is possible to add items to a menu at the specified index.

Example

The following example creates a File menu and calls getMenuAt(), which creates a reference to it. It then uses the reference to add two menu items, New and Open, to the File 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)
*/

var my_mb:mx.controls.MenuBar;

my_mb.addMenu("File");

var my_menu:mx.controls.Menu = my_mb.getMenuAt(0);
my_menu.addMenuItem({label:"New",instanceName:"newInst"});
my_menu.addMenuItem({label:"Open",instanceName:"openInst"});