# Customized tree component loading movieclips?

**URL:** <https://forum.kirupa.com/t/customized-tree-component-loading-movieclips/182911>\
**Category:** flash\
**Created:** [March 22, 2006, 12:03pm UTC](https://forum.kirupa.com/t/customized-tree-component-loading-movieclips/182911 "2006-03-22T12:03:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![W84me](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/w84me/32/1257_2.png) [@W84me](https://forum.kirupa.com/u/W84me)\
**Post date:** [March 22, 2006, 12:03pm UTC](https://forum.kirupa.com/t/customized-tree-component-loading-movieclips/182911/1 "2006-03-22T12:03:15Z")

</div>

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/](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**

```auto
<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**

```auto
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!!!
