# Tree Component Questions

**URL:** <https://forum.kirupa.com/t/tree-component-questions/184577>\
**Category:** flash\
**Created:** [April 6, 2006, 12:54am UTC](https://forum.kirupa.com/t/tree-component-questions/184577 "2006-04-06T00:54:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobby\_hamilton](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bobby\_hamilton](https://forum.kirupa.com/u/bobby_hamilton)\
**Post date:** [April 6, 2006, 12:54am UTC](https://forum.kirupa.com/t/tree-component-questions/184577/1 "2006-04-06T00:54:02Z")

</div>

[FONT=Arial][COLOR=#494920]Hey All,

I am populating a tree using an XML file and here is my question:

How do I have one of the branches of the tree expand showing its child nodes on load of my movie(without the user having to click on it)?

Thank you very much in advance for any insight.[/COLOR][/FONT]

---

<div class="post-metadata">

**Author:** ![bobby\_hamilton](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bobby\_hamilton](https://forum.kirupa.com/u/bobby_hamilton)\
**Post date:** [April 6, 2006, 1:02pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/2 "2006-04-06T13:02:00Z")

</div>

Anyone Please!!! :red:

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 6, 2006, 1:03pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/3 "2006-04-06T13:03:27Z")

</div>

umm… your gonna have to be more clear in what you are asking of us, I could show you 15 different ways to build a dynamic tree.

Post some code, that might help.

---

<div class="post-metadata">

**Author:** ![bobby\_hamilton](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bobby\_hamilton](https://forum.kirupa.com/u/bobby_hamilton)\
**Post date:** [April 6, 2006, 1:07pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/4 "2006-04-06T13:07:58Z")

</div>

ive got the tree, I just need to know how when the movie launches that it automatically opens the first branch for you.

thanx for the response!

---

<div class="post-metadata">

**Author:** ![bobby\_hamilton](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bobby\_hamilton](https://forum.kirupa.com/u/bobby_hamilton)\
**Post date:** [April 6, 2006, 3:10pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/5 "2006-04-06T15:10:51Z")

</div>

I know there’s gotta be someone who knows how to do this!

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [April 6, 2006, 4:06pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/6 "2006-04-06T16:06:32Z")

</div>

This should work:

```auto
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success) {
    trace("success");
    myTree.dataProvider = myXML.firstChild;
    myTree.setIsOpen(myTree.getTreeNodeAt(0), true, true, true);
};
myXML.load("tree.xml");

```

The only important part is that this function runs when it loads:

```auto
myTree.setIsOpen(myTree.getTreeNodeAt(0), true, true, true);

```

---

<div class="post-metadata">

**Author:** ![bobby\_hamilton](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bobby\_hamilton](https://forum.kirupa.com/u/bobby_hamilton)\
**Post date:** [April 6, 2006, 4:17pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/7 "2006-04-06T16:17:01Z")

</div>

Thats awesome!

---

<div class="post-metadata">

**Author:** ![bobby\_hamilton](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bobby\_hamilton](https://forum.kirupa.com/u/bobby_hamilton)\
**Post date:** [April 6, 2006, 4:17pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/8 "2006-04-06T16:17:36Z")

</div>

YOURE THE MAN!!! THANX SO

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [April 6, 2006, 4:19pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/9 "2006-04-06T16:19:48Z")

</div>

I’m glad it worked for you 🙂

---

<div class="post-metadata">

**Author:** ![Iammontoya](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@Iammontoya](https://forum.kirupa.com/u/Iammontoya)\
**Post date:** [April 6, 2006, 4:24pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/10 "2006-04-06T16:24:48Z")

</div>

It’s actually pretty easy, but of course not well documented.

Here’s the code:

```auto

var my_tr:mx.controls.Tree;

my_tr.setSize(200, 100);

var trDP_xml:XML = new XML();
trDP_xml.ignoreWhite = true;
trDP_xml.onLoad = function(success:Boolean){ 
   my_tr.dataProvider = trDP_xml.firstChild;
   my_tr.setIsOpen(my_tr.getTreeNodeAt(0), true); //this opens the root node
   my_tr.setIsOpen(my_tr.getTreeNodeAt(0).getTreeNodeAt(1), true);//this opens the second node under the root node

}
trDP_xml.load("mytree.xml");

```

And that’s all there is to it… remember that everything is 0 index. Meaning that the first one is actually zero the second is “one” and so on.

---

<div class="post-metadata">

**Author:** ![Iammontoya](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@Iammontoya](https://forum.kirupa.com/u/Iammontoya)\
**Post date:** [April 6, 2006, 4:25pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/11 "2006-04-06T16:25:32Z")

</div>

Ummm…yeah… ehhhe a little late.

---

<div class="post-metadata">

**Author:** ![bobby\_hamilton](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@bobby\_hamilton](https://forum.kirupa.com/u/bobby_hamilton)\
**Post date:** [April 6, 2006, 5:53pm UTC](https://forum.kirupa.com/t/tree-component-questions/184577/12 "2006-04-06T17:53:59Z")

</div>

a little, but thank you for the reply anyways! I appreciate the help!
