Hi all!
First of all sorry for my english i am trying hard to learn this language:book:
and also to learn actionscript…
I’ve made a customized tree component following this tutorial
http://www.sephiroth.it/tutorials/flashPHP/custom_tree/
It works great but i want when click at a node which has an atrribute mc=“amovieclip” to load the mc in the stage.
Here is a part of my xml file
<content label="Full Product List">
<cat label="Fresh Fruits And Vegetables">
<li label="Sweet and sour cherry" mc="cherry_mc" />
<li label="Apricot, peach, grapes seedless Thomson" mc="apgs_mc"/>
<li label="Strawberry, raspberry, blackberry" mc="berries_mc" />
<li label="Apples, plums" mc="aplplum_mc" />
<li label="Chestnuts" mc="chestnuts_mc" />
<li label="Peppers, tomatoes, etc." mc="peptom_mc" />
</cat>
</content>
And the code that needs to be modified
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);
The full code can be found at the link above.
Thanks in advance!!!