TREE METHODS
addEventListener
Availability
Flash Player 7.
Description
Adds an object as a listener to an event broadcast by a tree or its nodes. Once the tree fires the event, the method of the same name is fired on the listener object. If the optional eventMappedTo parameter is passed, then the function with the same name as this parameter is fired instead.
Arguments
addEventListener(event:String, listener:Object, eventMappedTo:String)
Returns
Boolean
Example
var treeListener:Object = {};
treeListener.select = function(infoObj:Object):Void { // some actions };
tree.addEventListener("select", treeListener);
// using eventMappedTo
var treeListener:Object = {};
treeListener.onNodeSelect = function(infoObj:Object):Void { // some actions };
tree.addEventListener("select", treeListener, "onNodeSelect");
addNode
Availability
Flash Player 7.
Description
Adds the specified new node to the end of the childNodes of the specified parent node in the tree.
Arguments
addNode(parentNode:TreeNode, newNode:TreeNode)
Returns
Nothing
Example
var node:TreeNode = new TreeNode();
node.nodeName = "www.27Bobs.com";
tree.addNode(tree.selectedNode, node);
tree.refresh();
addNodeAt
Availability
Flash Player 7.
Description
Adds the specified new node to the specified parent node in the tree at the specified index.
Arguments
addNodeAt(parentNode:TreeNode, newNode:TreeNode, index:Number)
Returns
Nothing
Example
var node:TreeNode = new TreeNode();
node.nodeName = "www.27Bobs.com";
tree.addNodeAt(tree.selectedNode, node, 0);
tree.refresh();
closeNode
Availability
Flash Player 7.
Description
Closes the specified node in the tree if it is currently displayed.
Arguments
closeNode(node:TreeNode)
Returns
Nothing
Example
tree.closeNode(tree.selectedNode);
deselectAll
Availability
Flash Player 7.
Description
Deselects all nodes visually and sets the tree's selectedNode property to null.
Arguments
None
Returns
Nothing
Example
tree.deselectAll();
deselectNode
Availability
Flash Player 7.
Description
Deselects the specified node visually and sets the tree's selectedNode property to null.
Arguments
deselectNode(node:TreeNode)
Returns
Nothing
Example
tree.deselectNode(tree.selectedNode);
expandAll
Availability
Flash Player 7.
Description
Opens all nodes in the tree.
Arguments
None
Returns
Nothing
Example
tree.expandAll();
findAttributeValue
Availability
Flash Player 7.
Description
Searches through tree from root node and returns first instance of node with the specified value for the specified attribute.
Arguments
findAttributeValue(attributeName:String, attributeValue:String)
Returns
TreeNode
Example
var node:TreeNode = tree.findAttributeValue("ID", "27");
tree.selectAndOpen(node);
findAttributeValueForNodeType
Availability
Flash Player 7.
Description
Searches through the node's childNodes array and returns first instance of node of the specified type with the specified value for the specified attribute.
Arguments
findAttributeValue(nodeName:String, attributeName:String, attributeValue:Object)
Returns
TreeNode
Example
var node:TreeNode = tree.findAttributeValueForNodeType("user", "ID", "27");
tree.selectAndOpen(node);
getEnabled
Availability
Flash Player 7.
Description
Enables the selection of nodes and the scrolling of the tree.
Arguments
None
Returns
Boolean
Example
if (!tree.getEnabled()) return;
getNodeAt
Availability
Flash Player 7.
Description
Returns the node at the specified index of the specified parent's childNodes.
Arguments
getNodeAt(parentNode:TreeNode, index:Number)
Returns
TreeNode
Example
tree.expandAll();
getScrollPosition
Availability
Flash Player 7.
Description
Returns an object containing the x and y position of the scrollbars in the scrollpane housing the tree.
Arguments
None
Returns
Object
Example
var pt:Object = tree.getScrollPosition();
tree.addNodeAt(tree.rootNode, 0);
tree.refresh();
tree.setScrollPosition(pt.x, pt.y);
loadFromXML
Availability
Flash Player 7.
Description
Loads an XML file from the specified URL, parses the data and displays it in the tree.
Arguments
loadFromXML(file:String)
Returns
Nothing
Example
tree.loadFromXML("data/structure.xml");
openNode
Availability
Flash Player 7.
Description
Opens the specified node in the tree if it is currently displayed.
Arguments
openNode(node:TreeNode)
Returns
Nothing
Example
tree.openNode(tree.rootNode);
openToNode
Availability
Flash Player 7.
Description
Opens the tree to reveal the specified node.
Arguments
openToNode(node:TreeNode)
Returns
Nothing
Example
var node:TreeNode = tree.findAttributeValue("ID", "27");
tree.openToNode(node);
populate
Availability
Flash Player 7.
Description
Removes the curent data from the tree and parses and displays the given XML.
Arguments
populate(xml:XML)
Returns
Nothing
Example
var treeXML:String = "<root><node1 /><node2 /></node3 /></root>";
tree.populate(new XML(treeXML));
refresh
Availability
Flash Player 7.
Description
Refreshes the display of the tree, necessary after a change has been made to its structure or its graphic parameters. If true is passed, the refresh is NOT animated (unless the tree's animateX and animateY parameters are false, in which case the tree would not animate either way).
Arguments
refresh(animated:Boolean)
Returns
Nothing
Example
var node:TreeNode = new TreeNode();
node.nodeName = "node1";
tree.addNode(tree.rootNode, node);
tree.refresh(true);
refreshSelected
Availability
Flash Player 7.
Description
Refreshes the visual display of only the selected node and its children.
Arguments
refreshSelected()
Returns
Nothing
Example
var node:TreeNode = new TreeNode();
node.nodeName = "node1";
tree.addNode(tree.selectedNode, node);
tree.refreshSelected(true);
removeAll
Availability
Flash Player 7.
Description
Clears the tree of all nodes.
Arguments
None
Returns
Nothing
Example
tree.removeAll();
tree.refresh();
removeDropLine
Availability
Flash Player 7.
Description
Removes the line or highlight drawn in the tree as feedback when dragging a node.
Arguments
None
Returns
Nothing
Example
tree.removeDropLine();
removeEventListener
Availability
Flash Player 7.
Description
Removes an object from the list of listeners to an event broadcast by a tree or its nodes. Once the tree fires the event, the method of the same name is fired on the listener object.
Arguments
removeEventListener(event:String, listener:Object)
Returns
Boolean
Example
tree.removeEventListener("select", treeListener);
removeNode
Availability
Flash Player 7.
Description
Deletes the specified node from the tree.
Arguments
removeNode(node:TreeNode)
Returns
Nothing
Example
tree.removeNode(tree.selectedNode);
tree.refresh();
removeNodeAt
Availability
Flash Player 7.
Description
Deletes the node from the specified node and index position in that node's childNodes array.
Arguments
removeNodeAt(parentNode:TreeNode, index:Number)
Returns
Nothing
Example
tree.removeNodeAt(tree.rootNode, 0);
tree.refresh();
removeNodesAt
Availability
Flash Player 7.
Description
Deletes the specified number of childNodes from the specified node starting from the index position.
Arguments
removeNodesAt(parentNode:TreeNode, index:Number, amount:Number)
Returns
Nothing
Example
tree.removeNodesAt(tree.rootNode, 0, 2);
tree.refresh();
renameNode
Availability
Flash Player 7.
Description
Selects the specified node, if currently displayed, and makes its label editable, highlighting the text.
Arguments
renameNode(parentNode:TreeNode)
Returns
Nothing
Example
tree.renameNode(tree.selectedNode);
selectAndOpen
Availability
Flash Player 7.
Description
Opens the tree to the specified node. Opens and selects the specified node as well.
Arguments
selectAndOpen(node:TreeNode)
Returns
Nothing
Example
var node:TreeNode = tree.findAttributeValue("ID", "27");
tree.selectAndOpen(node);
setEnabled
Availability
Flash Player 7.
Description
Enables the selection of nodes and the scrolling of the tree.
Arguments
setEnabled(enabled:Boolean)
Returns
Nothing
Example
tree.setEnabled(false);
setScrollPosition
Availability
Flash Player 7.
Description
Sets the x and y position of the scrollbars in the scrollpane housing the tree.
Arguments
setScrollPosition(x:Number, y:Number)
Returns
Nothing
Example
var pt:Object = tree.getScrollPosition();
tree.addNodeAt(tree.rootNode, 0);
tree.refresh();
tree.setScrollPosition(pt.x, pt.y);
setSize
Availability
Flash Player 7.
Description
Resizes the tree to the specified dimensions.
Arguments
setSize(width:Number, height:Number)
Returns
Nothing
Example
tree.setSize(300, 400);
toXML
Availability
Flash Player 7.
Description
Returns the tree's data as a string, formatted as XML. If true is passed as an argument, whitespace will be added to the XML for readability (tabs and linebreaks).
Arguments
toString(whitespace:Boolean)
Returns
String
Example
trace(tree.toXML(true));
var treeXML:XML = new XML(tree.toXML());
treeXML.send("http://mywebsite.com/sendXML.cfm", "_blank");
updateNodeLabel
Availability
Flash Player 7.
Description
Updates the displayed text in a node, useful when a node's attributes have changed, updating the label without refreshing the tree.
Arguments
updateNodeLabel(node:TreeNode)
Returns
Nothing
Example
tree.selectedNode.setAttribute("name", "new name");
tree.updateNodeLabel(tree.selectedNode);
updateStyles
Availability
Flash Player 7.
Description
Updates the visual display of the tree according to the parameters of the new styleFormat.
Arguments
updateStyles(format:StyleFormat)
Returns
Nothing
Example
var format:StyleFormat = new StyleFormat("newFormat");
format.face = 0xFF0000;
format.icon = 0xFFFFFF;
tree.updateStyles(format);