User Guide

782 Chapter 6: Components Dictionary
Version 2 components use a dispatcher/listener event model. The Tree component dispatches a
nodeOpen event when a node is clicked open by a user; 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
Tree.nodeOpen events event object has
one additional property:
node (the XML node that was opened).
For more information, see “EventDispatcher class” on page 415.
Example
In the following example, a handler called myTreeListener is defined and passed to
myTree.addEventListener() as the second parameter. The event object is captured by the
nodeOpen handler in the evtObject parameter. When the nodeOpen event is broadcast, a trace
statement is sent to the Output panel.
myTreeListener = new Object();
myTreeListener.nodeOpen = function(evtObject){
trace(evtObject.node + " node was opened");
}
myTree.addEventListener("nodeOpen", myTreeListener);
Tree.refresh()
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX Professional 2004.
Usage
myTree.refresh()
Parameters
None.
Returns
Nothing.
Description
Method; updates the tree.