User Guide

Using the MenuBar component (Flash Professional only) 947
visible is a Boolean value that indicates whether the object is visible (true) or not (false).
The default value is
true.
You cannot access the Labels parameter using ActionScript. However, you can write
ActionScript to control additional options for the MenuBar component using its properties,
methods, and events. For more information, see “MenuBar class (Flash Professional only)”
on page 951.
Creating an application with the MenuBar component
In this example, you drag a MenuBar component to the Stage, add code to add menu items to
it, and attach a listener to the menu to respond to the selection of a menu item.
To use a MenuBar component in an application:
1. Select File > New and create a new Flash document.
2. Drag the MenuBar component from the Components panel to the Stage.
3. Position the menu at the top of the Stage for a standard layout.
4. Select the MenuBar instance and, in the Property inspector, enter the instance name
my_mb.
5. In the Actions panel on Frame 1, enter the following code:
import mx.controls.Menu;
import mx.controls.MenuBar;
var my_mb:MenuBar;
var my_menu:Menu = my_mb.addMenu("File");
my_menu.addMenuItem({label:"New", instanceName:"newInstance"});
my_menu.addMenuItem({label:"Open", instanceName:"openInstance"});
my_menu.addMenuItem({label:"Close", instanceName:"closeInstance"});
This code adds a File menu to the MenuBar instance. It then uses a Menu method to add
three menu items: New, Open, and Close.
NOTE
The minHeight and minWidth properties are used by internal sizing routines. They are
defined in UIObject, and are overridden by different components as needed. These
properties can be used if you make a custom layout manager for your application.
Otherwise, setting these properties in the Component inspector has no visible effect.