# XML Tree Menu Help

**URL:** <https://forum.kirupa.com/t/xml-tree-menu-help/207810>\
**Category:** flash\
**Created:** [November 21, 2006, 6:48pm UTC](https://forum.kirupa.com/t/xml-tree-menu-help/207810 "2006-11-21T18:48:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hogfish](https://avatars.discourse-cdn.com/v4/letter/h/b19c9b/32.png) [@hogfish](https://forum.kirupa.com/u/hogfish)\
**Post date:** [November 21, 2006, 6:48pm UTC](https://forum.kirupa.com/t/xml-tree-menu-help/207810/1 "2006-11-21T18:48:38Z")

</div>

guys, I found this tutorial on the web for a Tree Menu powered by XML. It works fine except I cannot get it to link to anything. I have attached the file with source, and xml just like I downloaded it. Can anyone help me? Thanks

Tutorial Location:[http://www.sephiroth.it/tutorials/flashPHP/custom\_tree/index.php](http://www.sephiroth.it/tutorials/flashPHP/custom_tree/index.php)

PS

I am just trying to get it to load an external .swf into my main movie. I can’t even get it to link to an external site so something is missing or worng.

Thanks

File is too large to upload: Here is the source:

It has an XML connection node.

// Source begins here:  
//Frame 1 (Prototypes)

/\*\*

- Verify if the current XMLNODE is a child node
- of the passed node  
_/  
XMLNode.prototype.isChildNodeOf = function (targetParent:XMLNode) {  
var ret:Boolean = false;  
var myParent:XMLNode = this;  
while (myParent.parentNode != undefined) {  
if (myParent == targetParent) {  
ret = true;  
break;  
}  
myParent = myParent.parentNode;  
}  
return ret;  
};  
/_\*
- Return a list of sibling nodes of the parent node  
\*/  
XMLNode.prototype.getBrotherChilds = function (cTree:mx.controls.Tree) {  
var parent = this.parentNode;  
for (var a = 0; a \< parent.childNodes.length; a++) {  
if (parent.childNodes[a] != this and cTree.getIsOpen (parent.childNodes[a])) {  
return parent.childNodes[a];  
}  
}  
return undefined;  
};

// Second set of code on another layer Frame 1  
var treeListener:Object = new Object ();  
treeListener.target = tree;  
treeListener.opened = undefined;  
treeListener.open\_next = undefined;  
/\* a node in the tree has been selected \*/  
treeListener.change = function (evt:Object) {  
var node = evt.target.selectedItem;  
var is\_open = evt.target.getIsOpen (node);  
var is\_branch = evt.target.getIsBranch (node);  
var node\_to\_close = node.getBrotherChilds (this.target);  
// close the opened node first  
if (this.target.getIsOpen (node\_to\_close) and this.target.getIsBranch (node\_to\_close)) {  
this.target.setIsOpen (node\_to\_close, false, true, true);  
this.open\_next = node;  
} else {  
if (is\_branch) {  
this.target.setIsOpen (node, true, true, true);  
} else {  
this.target.selectedNode = node;  
this.target.dispatchEvent ({type:“click”, target:evt.target});  
}  
this.open\_next = undefined;  
}  
};  
treeListener.closeNode = function (node:XMLNode) {  
for (var a in node.childNodes) {  
if (this.target.getIsOpen (node.childNodes[a])) {  
this.closeNode (node.childNodes[a]);  
}  
}  
this.target.setIsOpen (node, false, false);  
};  
treeListener.nodeClose = function (evt:Object) {  
this.closeNode (evt.node);  
if (this.open\_next != undefined and evt.target.getIsBranch (this.open\_next)) {  
evt.target.setIsOpen (this.open\_next, true, true, true);  
} else {  
evt.target.selectedNode = this.open\_next;  
this.target.dispatchEvent ({type:“click”, target:evt.target});  
this.open\_next = undefined;  
}  
};  
treeListener.nodeOpen = function (evt:Object) {  
evt.target.selectedNode = evt.node;  
};

// set out listeners for the menu  
tree.addEventListener (‘change’, treeListener);  
tree.addEventListener (‘nodeClose’, treeListener);  
tree.addEventListener (‘nodeOpen’, treeListener);

// third set of code on another layer Frame 1 (Styles)

// get the menu XML  
this.xml\_conn.trigger();

// customize tree styles  
this.tree.setStyle(“fontFamily”, this.test\_text.getTextFormat().font);  
this.tree.setStyle(“fontSize”, this.test\_text.getTextFormat().size)  
this.tree.setStyle(“embedFonts”, this.test\_text.embedFonts)  
this.tree.setStyle(“fontWeight”, this.test\_text.getTextFormat().bold ? “bold” : “normal”)  
this.tree.setStyle(“depthColors”, [0x003366,0x013972,0x014383,0x01498F,0x01509C,0x0153A3])  
this.tree.setStyle(“backgroundColor”,0xFFFFFF)  
this.tree.setStyle(“borderStyle”, “none”);  
this.tree.setStyle(“color”,0xFFFFFF);  
this.tree.setStyle(“textIndent”,0);  
this.tree.setStyle(“indentation”,0);  
this.tree.setStyle(“rollOverColor”,0xFFFFFF);  
this.tree.setStyle(“selectionColor”, 0x666666);  
this.tree.setStyle(“selectionDuration”,0);  
this.tree.setStyle(“textRollOverColor”, 0x000000);  
this.tree.setStyle(“textSelectedColor”,0x000000);  
this.tree.setStyle(“defaultLeafIcon”, “nullicon”);  
this.tree.setStyle(“folderOpenIcon”, “nullicon”);  
this.tree.setStyle(“folderClosedIcon”, “nullicon”);  
this.tree.setStyle(“disclosureClosedIcon”, “nullicon”);  
this.tree.setStyle(“disclosureOpenIcon”, “nullicon”);  
this.tree.vScrollPolicy = ‘off’  
// set a custom cell renderer for the Tree  
// See treecellrenderer.as file for details  
this.tree.cellRenderer = ‘customTreeRow’  
// These 2 styles will be used by the  
// custom cellrenderer  
this.tree.setStyle(“lineColor”, 0x000000);  
this.tree.setStyle(“lineAlpha”, 20);
