Yeah, actually, I JUST worked this out for Xray last night during the
playoffs (GO STEELERS!!!)

what you have to do is use appendChild() of the XMLNode object.

Here's the code I'm using, hopefully, you can pick up what I'm doing from
this snippet:

// first, close the node if it's showing.  For some reason,
// closing first, then opening it after you add the children
// makes it work more smoothly
tree.setIsOpen(tree.getNodeDisplayedAt(indexClicked), false);

// grab the XMLNode to appendChild to
var parentXML = tree.getNodeDisplayedAt(indexClicked);

// XMLChild is XML sent in that has several children to add
// We have to loop through them all and see if they already
// exist.
for(var i:Number=0;i<XMLChild.childNodes.length;i++)
{
    // if you don't clone the node, it'll be taken from your current
XMLChild and
    // your loop will fail since it keeps getting smaller.  The node
    // is actually moved when you use appendChild.
    var addedNode:XMLNode = XMLChild.childNodes[i].cloneNode(true);

    // set exists flag
    var exists:Boolean = false;
    for(var j:Number=0;j<parentXML.childNodes.length;j++)
    {
        // match an attribute you would consider to be unique
        if(parentXML.childNodes[j].attributes.mc == addedNode.attributes.mc)
        {
            // if you find a match, break loop
            exists  = true;
            break;
        }
    }

    if(!exists)
    {
        // if you didnt' find a match, call appendChild()
        parentXML.appendChild(addedNode);

        // when I generate my XMLChild that comes in,
        // I asses whether or not the child has children of it's own.
        // If it DOES, then setIsBranch will give the node an arrow
        if(addedNode.attributes.isBranch == "true") tree.setIsBranch(addedNode,
true)
    }
}
// re-open node
tree.setIsOpen(parentXML, true);

hth,

John

On 1/23/06, Tien Nguyen <[EMAIL PROTECTED]> wrote:
>
> Thanks for the GREAT feedback on my last question.
>
> Since this list is so knowledgeable, how would one add lines to the Flash8
> tree.  Something like this link.
>
> http://www.treemenu.net/treemenu/3fr_beenthere.html
>
> Do you think that the flash8 tree is able to do this javascript tree.
>
> Thanks,
>
> Tim
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



--
John Grden - Blitz
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to