When the event is triggered, it automatically passes an event object (
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
object has one additional property:
node) that the pointer rolled over.
For more information, see
Example
The following example creates a menu with two items and a listener for a
When the
rollOver
, displays the name of the menu item for which the event occurred.
menuListener
You first drag a Menu component to the library and then add the following code to Frame 1:
/**
Requires:
- Menu component in library
*/
import mx.controls.Menu;
// Create an XML object to act as a factory.
var my_xml:XML = new XML();
// The item created next does not appear in the menu.
// The createMenu() method call (below) expects to
// receive a root element whose children will become
// the items. This is just a simple way to create that
// root element and give it a convenient name.
var menuDP_obj:Object = my_xml.addMenuItem("XXXXX");
// Add the menu items.
menuDP_obj.addMenuItem({label:"1st Item"});
menuDP_obj.addMenuItem({label:"2nd Item"});
// Create the Menu object.
var my_menu:Menu = Menu.createMenu(this, menuDP_obj);
// Show and position the menus
my_menu.show(100, 20);
// Create listener object.
var menuListener:Object = new Object();
menuListener.rollOver = function(evt_obj:Object) {
trace("Menu rollOver: "+evt_obj.menuItem.attributes.label);
};
// Add listener.
my_menu.addEventListener("rollOver", menuListener);
928
Menu component (Flash Professional only)
menuItem
"EventDispatcher class" on page
event is broadcast, a
trace
Menu.rollOver
, which is a reference to the menu item (XML
499.
() function in the event handler,
) to the
eventObject
event's event
event.
rollOver
Need help?
Do you have a question about the FLASH 8-COMPONENTS LANGUAGE and is the answer not in the manual?