User Guide

Menu component (Flash Professional only) 565
Version 2 components use a dispatcher-listener event model. When a Menu component
broadcasts a
rollOut event, the event is handled by a function (also called a handler) that is
attached to a listener object (
listenerObject) that you create. You call the
addEventListener() method and pass it the name of the handler as a parameter.
When the event is triggered, it automatically passes an event object (
eventObject) to the
handler. Each event object has properties that contain information about the event. You can use
these properties to write code that handles the event. The
Menu.rollOut events event object has
one additional property:
menuItem, which is a reference to the menu item (XML node) that the
pointer rolled off.
For more information, see “EventDispatcher class” on page 415.
Example
In the following example, a handler called form is defined and passed to
myMenu.addEventListener() as the second parameter. The event object is captured by the
rollOut handler in the evt parameter. When the rollOut event is broadcast, a trace statement
is sent to the Output panel.
form = new Object();
form.rollOut = function(evt){
trace("Menu rollOut: "+evt.menuItem.attributes.label);
}
myMenu.addEventListener("rollOut", form);
Menu.rollOver
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX Professional 2004.
Usage
listenerObject = new Object();
listenerObject.rollOver = function(eventObject){
// insert your code here
}
myMenu.addEventListener("rollOver", listenerObject)
Description
Event; broadcast to all registered listeners when the pointer rolls over a menu item.
Version 2 components use a dispatcher-listener event model. When a Menu component
broadcasts a
rollover event, the event is handled by a function (also called a handler) that is
attached to a listener object (
listenerObject) that you create. You call the
addEventListener() method and pass it the name of the handler as a parameter.