Developer Network Home  Help 

YDN Flash Developer Center Astra Flash Components Menu
Flash Developer Center

ASTRA Menu

Menu is a UI component that displays a hierarchical menu structure that can be used to provide convenient access to various application functionality, sorted by categories.

Getting Started: Menu for Flash CS3

Similar to other Flash components, you can create a Menu by placing an instance on the stage or by using ActionScript to create an instance dynamically.

Initializing a Menu on the Stage

One way to create a Menu is to drag it from the Components panel to the stage and give it a name in the Properties panel (we'll use the name "menu" in this example). This will immediately create a Menu instance and add it to the display list. To populate it and show the menu, you'll need to use ActionScript. So we'll show how to do that.

Screen capture of Menu

To see a live example, please install Adobe Flash Player version 9 or higher.

Download the FLA file.

Initializing a Menu with ActionScript

To include a Menu within your application with ActionScript, you must first add the Menu component to your library. You can do so by dragging it from the Components panel directly to the library, or by dragging an instance to the stage, and immediately removing it (it will stay in your library). Additionally, you need to import the following classes for use in your class or frame script.

The class com.yahoo.astra.fl.controls.Menu is the main required class for a Menu control.

To create the menu, you call the Menu.createMenu() method. This is a static method, so you actually call it on the Menu class (hence the uppercase "Menu"). This method takes a couple of parameters; the first is the object you want your menu to be attached to, and the second is some XML data. Note that the first parameter will affect its placement in terms of layering for the display list (i.e. what goes on top of what), as well as its x,y placement.

For additional topics, please read Using Menu, or take a look at the Examples section for functional demonstrations. The ActionScript 3.0 Class Reference contains full details on every property, method, and style available to the Menu component.