AS XML tree help

  • Started
  • Last post
  • 2 Responses
  • ninjasavant

    Complete coding n00b here. I'm trying to create a tree in Flash using ActionScript. The help has the code at the bottom of this post and it makes XML for the tree but it only has one top level node with child nodes. I want to add several top level nodes with child nodes but I can only figure out how to add top level nodes with any child nod going under the first node. Anyone know what I'm talking about and how to make it work? Thanks

    // Create an XML object.
    var myTreeDP:XML = new XML();
    // Create node values.
    var myNode0:XMLNode = myTreeDP.createElement("node");
    myNode0.attributes.label = "Local Folders";
    myNode0.attributes.data = 0;
    var myNode1:XMLNode = myTreeDP.createElement("node");
    myNode1.attributes.label = "Inbox";
    myNode1.attributes.data = 1;
    var myNode2:XMLNode = myTreeDP.createElement("node");
    myNode2.attributes.label = "Outbox";
    myNode2.attributes.data = 2;
    var myNode3:XMLNode = myTreeDP.createElement("node");
    myNode3.attributes.label = "Sent Items";
    myNode3.attributes.data = 3;
    var myNode4:XMLNode = myTreeDP.createElement("node");
    myNode4.attributes.label = "Deleted Items";
    myNode4.attributes.data = 4;
    // Assign nodes to the hierarchy in the XML tree.
    myTreeDP.appendChild(myNode0);
    myTreeDP.firstChild.appendChild...
    myTreeDP.firstChild.appendChild...
    myTreeDP.firstChild.appendChild...
    myTreeDP.firstChild.appendChild...
    // Assign the myTreeDP data source to the Tree component.
    myTree.dataProvider = myTreeDP;

  • maximillion_0

    dont create them at the top level, use the first children as you top level and then create child nodes in those nodes. the levels can then be endless.

  • ninjasavant0

    How would that look in the code? I've tried:

    myTreeDP.appendChild(myNode1);
    myTreeDP.appendChild.appendChild...
    myTreeDP.appendChild(myNode3);
    myTreeDP.appendChild.appendChild...

    and only node 1 and 3 show up.