TREENODE METHODS
addNode
Availability
Flash Player 7.
Description
Adds the specified new node to the end of the childNodes array.
Arguments
addNode(newNode:TreeNode)
Returns
Nothing
Example
var node:TreeNode = new TreeNode();
node.nodeName = "www.27Bobs.com";
tree.selectedNode.addNode(node);
tree.refresh();
addNodeAt
Availability
Flash Player 7.
Description
Adds the specified new node to the childNodes array at the specified index.
Arguments
addNodeAt(newNode:TreeNode, index:Number)
Returns
Nothing
Example
var node:TreeNode = new TreeNode();
node.nodeName = "www.27Bobs.com";
tree.selectedNode.addNodeAt(node, 0);
tree.refresh();
copyNode
Availability
Flash Player 7.
Description
Creates a deep clone of the node.
Arguments
None
Returns
TreeNode
Example
var node:TreeNode = tree.selectedNode.copy();
tree.rootNode.addNodeAt(node, 0);
tree.refresh();
findAttributeValue
Availability
Flash Player 7.
Description
Searches through the node's childNodes array and returns first instance of node with the specified value for the specified attribute.
Arguments
findAttributeValue(attributeName:String, attributeValue:Object)
Returns
TreeNode
Example
var node:TreeNode = tree.selectedNode.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.selectedNode.findAttributeValueForNodeType("user", "ID", "27");
tree.selectAndOpen(node);
findIndex
Availability
Flash Player 7.
Description
Returns the node's position in its parent's childNodes array.
Arguments
findIndex()
Returns
Number
Example
var index:Number = tree.selectedNode.findIndex();
var node:TreeNode = new TreeNode();
node.nodeName = "newNode";
tree.selectedNode.parentNode.addNodeAt(node, index+1);
tree.refresh();
getAttribute
Availability
Flash Player 7.
Description
Returns the value for the specified attribute.
Arguments
getAttribute(attributeName:String)
Returns
String
Example
var ID:Number = Number(tree.selectedNode.getAttribute("ID"));
getNumChildren
Availability
Flash Player 7.
Description
Returns the number of nodes in the childNodes array.
Arguments
None
Returns
Number
Example
var lastNodeIndex:Number = tree.rootNode.getNumChildren() - 1;
var lastNode:TreeNode = tree.getNodeAt(tree.rootNode, lastNodeIndex);
tree.removeNode(lastNode);
tree.refresh();
isChildOf
Availability
Flash Player 7.
Description
Returns whether node is contained anywhere within the specified node.
Arguments
None
Returns
Boolean
Example
if (node.isChildOf(otherNode)) return;
parseNode
Availability
Flash Player 7.
Description
Populates node with specified XML.
Arguments
XML
Returns
Nothing
Example
var xml:XML = new XML("<one><two /></one>");
var node = new TreeNode();
node.nodeName = "newNode";
node.parseNode(xml);
tree.rootNode.addNode(node);
tree.refresh();
remove
Availability
Flash Player 7.
Description
Removes the node from the tree.
Arguments
None
Returns
Nothing
Example
tree.selectedNode.remove();
tree.refresh();
removeAll
Availability
Flash Player 7.
Description
Removes all childNodes from the node.
Arguments
None
Returns
Nothing
Example
tree.selectedNode.removeAll();
tree.refresh();
removeAttribute
Availability
Flash Player 7.
Description
Removes specified attribute from node.
Arguments
String
Returns
Nothing
Example
tree.selectedNode.removeAttribute("special");
removeNodeAt
Availability
Flash Player 7.
Description
Deletes the node at the specified index position in the childNodes array.
Arguments
removeNodeAt(index:Number)
Returns
Nothing
Example
tree.rootNode.removeNodeAt(0);
tree.refresh();
removeNodesAt
Availability
Flash Player 7.
Description
Deletes the nodes from the childNodes array from the specified index position for the number of nodes specified.
Arguments
removeNodesAt(index:Number, numNodes:Number)
Returns
Nothing
Example
tree.rootNode.removesNodeAt(0, 3);
tree.refresh();
setChildNodes
Availability
Flash Player 7.
Description
Clears the childNodes array and replaces it with the array passed in.
Arguments
setChildNodes(nodes:Array)
Returns
Nothing
Example
var nodes:Array = [];
var node:TreeNode = new TreeNode();
node.nodeName = "node1";
nodes.push(node);
node = new TreeNode();
node.nodeName = "node2";
nodes.push(node);
node = new TreeNode();
node.nodeName = "node3";
nodes.push(node);
tree.selectedNode.setChildNodes(nodes);
tree.refresh();
setData
Availability
Flash Player 7.
Description
Repopulates the node with the specified XML formatted as a string.
Arguments
setData(xmlStr:XML)
Returns
Nothing
Example
tree.populate(new XML());
tree.rootNode.setData("<root><one /><two /><three /></root>");
tree.refresh();
setNodeProperties
Availability
Flash Player 7.
Description
Alters the nodeName, attributes and nodeValue of a node in a single call.
Arguments
setNodeProperties(name:String, value:String, attributes:Object)
Returns
Nothing
Example
tree.rootNode.setNodeAttributes("base", null, {id:"1"});
tree.refresh();
toString
Availability
Flash Player 7.
Description
Returns the data of the tree formatted as a string in an XML structure with whitespace (linebreaks and tabs).
Arguments
None
Returns
String
Example
texfield.text = tree.selectedNode.toString();
trace(tree.selectedNode); // trace calls toString() method of object
toXML
Availability
Flash Player 7.
Description
Returns the data of the tree formatted as a string in an XML structure. Whitespace may be added (linebreaks and tabs).
Arguments
toXML(whitespace:Boolean, initialWhitespace:String, memory:Boolean)
Passing true for memory will insert extra attributes into the XML, making it possible upon refreshing the tree with new and slightly modified XML to maintain the current open/closed structure of the tree.
Returns
String
Example
textfield.text = tree.selectedNode.toXML(true);
var nodeXML:XML = new XML(tree.selectedNode.toXML(false, null, true));
nodeXML.onLoad = parseNewData;
nodeXML.sendAndLoad("http://mywebsite.com/sendXML.cfm", "_blank", nodeXML);