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

ActionScript Events

InheritanceMovieClip > UIObject class > AccordionTreeMenu class

Events inherited from the UIObject class

The following table lists the events the AccordionTreeMenu 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 AccordionTreeMenu class

The following table lists events of the AccordionTreeMenu class.

Event Description
AccordionTreeMenu.click Broadcast when a menu item is clicked.
AccordionTreeMenu.closing Broadcast when a top level item is closing.
AccordionTreeMenu.onLoadXML Broadcast when the component attempts to load an XML file.
AccordionTreeMenu.opening Broadcast when a top level item is opening.
AccordionTreeMenu.rollOut Broadcast when the pointer rolls off a menu item.
AccordionTreeMenu.rollOver Broadcast when the pointer rolls over a menu item.

AccordionTreeMenu.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) 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 Accordion Tree Menu 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");
}


AccordionTreeMenu.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 Accordion Tree Menu component is closing.

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 Accordion Tree Menu 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 that can retrieve the following values:

  • start(String) Triggers when the nested second level sub-menu starts moving up.
  • moving(String) Triggers continuously while the nested second level sub-menu keeps moving up.
  • stop(String) Triggers when the nested second level sub-menu stops moving up.

Example

This example, written on a frame of the Timeline, sends messages to the Output panel when the top level item is closing.

menuListener = new Object();
menuListener.closing = function(eventObj) {
if (eventObj.data == "start") trace("menu item starts closing");
if (eventObj.data == "moving") trace("menu item keeps moving");
if (eventObj.data == "stop") trace("menu item stops closing");
}
my_menu.addEventListener("closing", menuListener);

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

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


AccordionTreeMenu.onLoadXML

Usage

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

Description

Event; broadcast when the Accordion Tree Menu 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);


AccordionTreeMenu.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 Accordion Tree Menu component is opening.

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 Accordion Tree Menu 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 that can retrieve the following values:

  • start(String) Triggers when the nested second level sub-menu starts moving down.
  • moving(Integer) Triggers continuously while the nested second level sub-menu keeps moving down.
  • stop(String) Triggers when the nested second level sub-menu stops moving down.

Example

This example, written on a frame of the Timeline, sends messages to the Output panel when the top level item is opening.

menuListener = new Object();
menuListener.opening = function(eventObj) {
if (eventObj.data == "start") trace("menu item starts opening");
if (eventObj.data == "moving") trace("menu item keeps moving");
if (eventObj.data == "stop") trace("menu item stops opening");
}
my_menu.addEventListener("opening", menuListener);

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

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


AccordionTreeMenu.rollOut

Usage

Usage 1:

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

Usage 2:

on(rollOut) {
// Your code here
}

Description

Event; broadcast to all registered listeners when the pointer rolls off a menu item.

The usage example uses a dispatcher/listener event model. A component instance (my_menu) dispatches an event (in this case, rollOut) 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 Accordion Tree Menu instance my_menu, sends "_level0.my_menu" to the Output panel:

on(rollOut) {
trace(this);
}

Event object

Contains the following two properties:

  • indexAn integer that indicates the index position of the menu item that the pointer rolled off.
  • areaA string that indicates the area to which the pointer rolled off. There are two possible values of this property: "inside", "outside".

Example

This example, written on a frame of the Timeline, sets the rollout_item variable to the value of the "label" attribute of the menu item that the pointer rolled off. 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 rollout_item:String;
menuListener = new Object();
menuListener.rollOut = function(eventObj) {
rollout_item = eventObj.target.getItemAt(eventObj.data.index).label;
}
my_menu.addEventListener("rollOut", menuListener);

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

on(rollOut) {
trace("the pointer rolls off a menu item");
}


AccordionTreeMenu.rollOver

Usage

Usage 1:

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

Usage 2:

on(rollOver) {
// Your code here
}

Description

Event; broadcast to all registered listeners when the pointer rolls over a menu item.

The usage example uses a dispatcher/listener event model. A component instance (my_menu) dispatches an event (in this case, rollOver) 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 Accordion Tree Menu instance my_menu, sends "_level0.my_menu" to the Output panel:

on(rollOver) {
trace(this);
}

Event object

Contains the following two properties:

  • indexAn integer that indicates the index position of the menu item that the pointer rolled over.
  • areaA string that indicates the area to which the pointer rolled over. There are two possible values of this property: "inside", "outside".

Example

This example, written on a frame of the Timeline, sets the rollover_item variable to the value of the "label" attribute of the menu item that the pointer rolled over. 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 rollover_item:String;
menuListener = new Object();
menuListener.rollOver = function(eventObj) {
rollover_item = eventObj.target.getItemAt(eventObj.data.index).label;
}
my_menu.addEventListener("rollOver", menuListener);

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

on(rollOver) {
trace("the pointer rolls over a menu item");
}


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