TREENODE METHODS
addNode
Availability
Flash Player 9.
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 9.
Description
Adds the specified new node to the childNodes array at the specified index.
Arguments
addNodeAt(index:uint, node:TreeNode)
Returns
Nothing
Example
var node:TreeNode = new TreeNode();
node.nodeName = "www.27Bobs.com";
tree.selectedNode.addNodeAt(0, node);
tree.refresh();
copyNode
Availability
Flash Player 9.
Description
Creates a deep clone of the node.
Arguments
None
Returns
TreeNode
Example
var node:TreeNode = tree.selectedNode.copy();
tree.rootNode.addNodeAt(0, node);
tree.refresh();
findAttributeValue
Availability
Flash Player 9.
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:String)
Returns
TreeNode
Example
var node:TreeNode = tree.selectedNode.findAttributeValue("ID", "27");
tree.openToAndSelect(node);
findAttributeValueForNodeType
Availability
Flash Player 9.
Description
Searches through the node's childNodes array and returns first instance of node of the specified node type with the specified value for the specified attribute.
Arguments
findAttributeValueForNodeType(nodeType:String, attributeName:String, attributeValue:String)
Returns
TreeNode
Example
var node:TreeNode = tree.selectedNode.findAttributeValueForNodeType("user", "ID", "27");
tree.openToAndSelect(node);
findIndex
Availability
Flash Player 9.
Description
Returns the node's position in its parent's childNodes array.
Arguments
findIndex()
Returns
uint
Example
var index:uint = tree.selectedNode.findIndex();
var node:TreeNode = new TreeNode();
node.nodeName = "newNode";
tree.selectedNode.parentNode.addNodeAt(index+1, node);
tree.refresh();
getAttribute
Availability
Flash Player 9.
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 9.
Description
Returns the number of nodes in the childNodes array.
Arguments
None
Returns
uint
Example
var lastNodeIndex:int = tree.rootNode.getNumChildren() - 1;
var node:TreeNode = new TreeNode();
tree.rootNode.addNodeAt(lastNodeIndex, node);
tree.refresh();
isChildOf
Availability
Flash Player 9.
Description
Returns whether node is contained anywhere within the specified node.
Arguments
isChildOf(node:TreeNode)
Returns
Boolean
Example
if (node.isChildOf(otherNode)) return;
parse
Availability
Flash Player 9.
Description
Forces node to parse its XML data. By default, to optimize rendering of the tree, a node does not parse its data unless it is opened. Unparsed nodes cannot be searched through or have childnodes accessed.
Arguments
parse(parseChildren:Boolean)
Returns
Nothing
Example
tree.rootNode.parse(true);
var node:TreeNode = tree.findAttributeValue("ID", "27");
tree.openToAndSelect(node);
parseNode
Availability
Flash Player 9.
Description
Populates node with specified XML.
Arguments
parseNode(data:XML)
Returns
Nothing
Example
var xml:XML = new XML("<one><two /></one>");
var node = new TreeNode();
node.parseNode(xml);
tree.rootNode.addNode(node);
tree.refresh();
remove
Availability
Flash Player 9.
Description
Removes the node from the tree.
Arguments
None
Returns
Nothing
Example
tree.selectedNode.remove();
tree.refresh();
removeAllChildren
Availability
Flash Player 9.
Description
Removes all childNodes from the node.
Arguments
None
Returns
Nothing
Example
tree.selectedNode.removeAllChildren();
tree.refresh();
removeAttribute
Availability
Flash Player 9.
Description
Removes specified attribute from node.
Arguments
String
Returns
Nothing
Example
tree.selectedNode.removeAttribute("special");
removeNodeAt
Availability
Flash Player 9.
Description
Deletes the node at the specified index position in the childNodes array.
Arguments
removeNodeAt(index:uint)
Returns
Nothing
Example
tree.rootNode.removeNodeAt(0);
tree.refresh();
removeNodesAt
Availability
Flash Player 9.
Description
Deletes the nodes from the childNodes array from the specified index position for the number of nodes specified.
Arguments
removeNodesAt(index:uint, numNodes:uint)
Returns
Nothing
Example
tree.rootNode.removesNodeAt(0, 3);
tree.refresh();
setAttribute
Availability
Flash Player 9.
Description
Sets the value for a single attribute of the node.
Arguments
setAttribute(name:String, value:String)
Returns
Nothing
Example
tree.rootNode.setAttribute("valid", "true");
setChildNodes
Availability
Flash Player 9.
Description
Clears the childNodes array and replaces it with the array or XMLList passed in.
Arguments
setChildNodes(nodes:Object)
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 9.
Description
Repopulates the node with the specified XML or string formatted as XML.
Arguments
setData(xmlStr:Object)
Returns
Nothing
Example
tree.populate(new XML());
tree.rootNode.setData("<root><one /><two /><three /></root>");
tree.refresh();
setNodeProperties
Availability
Flash Player 9.
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 9.
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 9.
Description
Returns the data of the tree formatted as a string in an XML structure.
Arguments
None
Returns
String
Example
textfield.text = tree.selectedNode.toXML(true);
var nodeXML:XML = new XML(tree.selectedNode.toXML());
nodeXML.onLoad = parseNewData;
nodeXML.sendAndLoad("http://mywebsite.com/sendXML.cfm", "_blank", nodeXML);