MenuBar is a UI component that renders hierarchical data as a row of buttons with nested menus that can be used to provide convenient access to various application functionality.
Using MenuBar in Flash CS3
In Getting Started, we created a simple MenuBar. We will add icons to the MenuBar.
Before we dive into the code, let's take a look at how icons can be added to the MenuBar component. Icons can be added to a menu item through the attributes of it's corresponding xml node. There are 2 ways to add icons to with the MenuBar component.
- Assigning a radio button or a check through the type attribute.
- Assigning a selected and deselected icon classes through the selectedIcon and icon attributes.
Below is a node with a radio button assigned:
Here is the same node with a check icon assigned:
You can also assign custom icons through the icon and selectedIcon attributes.
Note: You will need to create matching skins in the library to specify icons through these attributes.
You can also create a toggling effect with icons in a menu by assigning them to a group. Below is an example using a check:
Here is an example using a custom icon:
Now that we know how to add icons to the MenuBar component, let's build this example. As in our previous examples, we will import the MenuBar class.
Next, we will create an xml object using the attributes discussed above to add icons to the menu items.
Finally, create a
MenuBar instance and assign the xml object as its
Example: MenuBar with icons
To see a live example, please install Adobe Flash Player version 9 or higher.
Download the FLA file.
For additional information, please take a look at the Examples section for functional demonstrations and the ActionScript 3.0 Class Reference for full details on every property, method, and style available to the MenuBar component.