E-merald web-engineering Flash components
E-merald web-engineering Contact Site map
 
Home Components Support Purchase
Components

ActionScript Events

InheritanceMovieClip > UIObject class > GlobalMenuPro class

Events inherited from the UIObject class

The following table lists the events the GlobalMenuPro class inherits from the UIObject class.

Event Description
UIObject.hide Broadcast when an object's state changes from visible to invisible.
UIObject.reveal Broadcast when an object's state changes from invisible to visible.

Events unique to the GlobalMenuPro class

The following table lists events of the GlobalMenuPro class.

Event Description
GlobalMenuPro.click Broadcast when a menu item is clicked.
GlobalMenuPro.closing Broadcast when a top-level item is returning to the default state.
GlobalMenuPro.onLoadXML Broadcast when the component attempts to load an XML file.
GlobalMenuPro.opening Broadcast when a top-level item is rolled over.

GlobalMenuPro.click

Usage

Usage 1:

listenerObject = new Object();
listenerObject.click = function(eventObject) {
// Your code here
}
my_menu.addEventListener("click", listenerObject);

Usage 2:

on(click) {
// Your code here
}

Description

Event; broadcast to all registered listeners when the mouse is clicked (pressed and released) over a menu item.

The first usage example uses a dispatcher/listener event model. A component instance (my_menu) dispatches an event (in this case, click) and the event is handled by a function, also called a "handler", on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.

The second usage example uses an on() handler and must be attached directly to a menu instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to a Global Menu Pro instance my_menu, sends "_level0.my_menu" to the Output panel:

on(click) {
trace(this);
}

Event object

Along with the standard event object properties, the click event has one additional property — an integer that indicates the index position of the clicked menu item.

Example

This example, written on a frame of the Timeline, sets the selected_item variable to the value of the clicked menu item's "label" attribute. The target property of an event object is the component that generated the event. You can access instance properties and methods from the target property (in this example, the getItemAt() method is accessed).

var selected_item:String;
menuListener = new Object();
menuListener.click = function(eventObj) {
selected_item = eventObj.target.getItemAt(eventObj.data).label;
}
my_menu.addEventListener("click", menuListener);

The following code sends a message to the Output panel when a menu item is clicked. The on() handler must be attached directly to a menu instance.

on(click) {
trace("menu item was clicked");
}


GlobalMenuPro.closing

Usage

Usage 1:

listenerObject = new Object();
listenerObject.closing = function(eventObject) {
// Your code here
}
my_menu.addEventListener("closing", listenerObject);

Usage 2:

on(closing) {
// Your code here
}

Description

Event; broadcast to all registered listeners when a top-level item of the Global Menu Pro component is returning to its default (not rolled-over) state.

The first usage example uses a dispatcher/listener event model. A component instance (my_menu) dispatches an event (in this case, closing) and the event is handled by a function, also called a "handler", on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.

The second usage example uses an on() handler and must be attached directly to a menu instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to a Global Menu Pro instance my_menu, sends "_level0.my_menu" to the Output panel:

on(closing) {
trace(this);
}

Event object

Along with the standard event object properties, the closing event has one additional property — an integer that indicates the index position of the top-level menu item that is returning to its default state.

Example

This example, written on a frame of the Timeline, sets the cl_index variable to the value of the index position of the top-level menu item that is returning to its default state.

var cl_index:Number;
menuListener = new Object();
menuListener.closing = function(eventObj) {
cl_index = eventObj.data;
}
my_menu.addEventListener("closing", menuListener);

The following code sends a message to the Output panel when a top-level item is returning to its default state. The on() handler must be attached directly to a menu instance.

on(closing) {
trace("menu item is closing");
}


GlobalMenuPro.onLoadXML

Usage

listenerObject = new Object();
listenerObject.onLoadXML = function(eventObject) {
// Your code here
}
my_menu.addEventListener("onLoadXML", listenerObject);

Description

Event; broadcast when the Global Menu Pro component attempts to load an XML file.

The usage example uses a dispatcher/listener event model. A component instance (my_menu) dispatches an event (in this case, onLoadXML) and the event is handled by a function, also called a "handler", on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.

Event object

Contains a Boolean value ("true" or "false") to indicate whether an XML file was found.

Example

This example, written on a frame of the Timeline, uses the event object to set up a conditional statement that checks to see if an XML file was found and loaded.

menuListener = new Object();
menuListener.onLoadXML = function(eventObj) {
if (eventObj.data == true) {
// show success alert
} else {
// show error alert
}
}
my_menu.addEventListener("onLoadXML", menuListener);


GlobalMenuPro.opening

Usage

Usage 1:

listenerObject = new Object();
listenerObject.opening = function(eventObject) {
// Your code here
}
my_menu.addEventListener("opening", listenerObject);

Usage 2:

on(opening) {
// Your code here
}

Description

Event; broadcast to all registered listeners when a top-level item of the Global Menu Pro component is rolled over.

The first usage example uses a dispatcher/listener event model. A component instance (my_menu) dispatches an event (in this case, opening) and the event is handled by a function, also called a "handler", on a listener object (listenerObject) that you create. You define a method with the same name as the event on the listener object; the method is called when the event is triggered. When the event is triggered, it automatically passes an event object (eventObject) to the listener object method. The event object has properties that contain information about the event. You can use these properties to write code that handles the event. Finally, you call the EventDispatcher.addEventListener() method on the component instance that broadcasts the event to register the listener with the instance. When the instance dispatches the event, the listener is called.

The second usage example uses an on() handler and must be attached directly to a menu instance. The keyword this, used inside an on() handler attached to a component, refers to the component instance. For example, the following code, attached to a Global Menu Pro instance my_menu, sends "_level0.my_menu" to the Output panel:

on(opening) {
trace(this);
}

Event object

Along with the standard event object properties, the opening event has one additional property — an integer that indicates the index position of the rolled-over top-level menu item.

Example

This example, written on a frame of the Timeline, sets the op_index variable to the value of the index position of the top-level menu item that is rolled over.

var op_index:Number;
menuListener = new Object();
menuListener.opening = function(eventObj) {
op_index = eventObj.data;
}
my_menu.addEventListener("opening", menuListener);

The following code sends a message to the Output panel when a top-level item is rolled over. The on() handler must be attached directly to a menu instance.

on(opening) {
trace("menu item is opening");
}


© E-MERALD. All rights reserved.
© Designed by Fox.net.ua.