Tuesday, 14 July 2009

Adobe Flex MenuBar Component


This MenuBar component allows you to create 2-level menu bar in your Flex applications.

The component takes a dataProvider as an argument just like the MenuBar component provided
in Flex platform. But this component just takes dataProvider in XMLListCollection.

In the sample application, menuitem object contains label, requiresLogin and data fields.
  • label field is the displayed text for the given menuitem,
  • requiresLogin field keeps the information whether the given menu item needs login operation or not,
  • data field is used as the id descriptor of the given menu.
When creating a collection of menuitems, give unique data field values for each menuitem.

In the given source code of a sample project, you will see GradientCanvas and GradientHBox components. They are just used to give a gradient for the menubars.

MenuBarEvent keeps the clicked menuitem id, and the information whether the clicked menuitem requires login operation or not to enter that menu.
MenuData, MenuHierarchy, SubmenuData classes are just used for data structure of the menu bar.

Moreover, you will find Gray and Green css files used for the visuality. They are just samples to demonstrate how to give gradients of the menubars, selected menu item color, etc.