PDA

View Full Version : Tree component not working as described or expected


nytyme
08-30-2004, 08:49 PM
Greetings, I've been searching for information on the forums and on google for something that can explain and clarify what's going on.

I have a tree that I'm trying to use addTreeNodeAt() on, but it only works when it feels like it.
Assume this is my opened tree (toTree):
Catalog
--CD
----CD Title
----CD Band
----CD Genre
--Catalog Title

if i use .addTreeNodeAt() i can ONLY add for "Catalog" and "CD", but not the way I expect or is described. If I add a Node, it should be a child of the selected branch.

on(click){
var tix = _root.toTree.selectedIndex;
var node = _root.toTree.getNodeDisplayedAt(tix);
trace("The Selected Index is " + node.attributes.label + "\nYou should have a new tree node (but more than likely you won't");
_root.toTree.setIsBranch(_root.toTree.getTreeNodeA t(tix),true);
_root.toTree.setIsOpen(_root.toTree.getTreeNodeAt( tix),true);
_root.toTree.addTreeNodeAt(tix,"hello");
}


I've included the xml and fla i'm using, hopefully you can see how I've screwed up.

Thanks.


P.S. I keep seeing mention of "FTree" as part of Flash MX, but I can't find it.

Drakkon
08-30-2004, 09:22 PM
I'm kinda confused at to what your wanting to do...

So if you start with this:
--CD
----CD Title
----CD Band
----CD Genre

and you select CD (folder) and press your button you want this:

--CD
----CD Title
----CD Band
----CD Genre
----hello

or do you want:

--CD
----CD Title
----CD Band
----CD Genre
--hello

nytyme
08-30-2004, 11:10 PM
Correct.
I start with this in (toTree):
Catalog
--CD
----CD Title
----CD Band
----CD Genre
--Catalog Title

if i click CD Title and hit the button, I want to have this:
Catalog
--CD
----CD Title
------Hello
----CD Band
----CD Genre
--Catalog Title

granted it's simplistic, eventually it'll be more useful, but so far it doesn't work period.

Drakkon
08-31-2004, 12:30 AM
wow the only info I've found is negative that the tree compoent is screwy when it comes to "addTreeNodeAt" and references the Tree rather than the XML. For example (and this makes no sense whatsoever to me) put in:
trace("The Selected Index is " + tix);
trace(tix +" = " + _root.toTree.getTreeNodeAt(tix));
trace("2 = " + _root.toTree.getTreeNodeAt(2));
after your var declarations and its like selectedIndex in no way correlates to getTreeNodeAt.

So it looks like the only way to "fix" it is to instead of trying to add tree nodes create XML nodes instead, manipulate them in XML, and then redaw the tree using the "new" xml as a dataprovider.

nytyme
08-31-2004, 01:08 AM
Funny you should say that, I'm actually in the process of doing that.

I'm building a string that contains the node information, but I can't seem to get it be a real node...

i call a function that takes the selectedIndex and goes through the XML nodes until it hits the index, then it returns a string, that maps to the node. For example, if I click "CD Band", i get this string back: ".childNodes[0].childNodes[0].childNodes[1]", which is the right location. however, i can't figure out how to do anything with it. eval doesn't work. i want to appendChild to that returned node and redaw it (i just need to use toTree.dataProvider = xmlfile).

if you know how i can take the string returned and use it reference the XMLnode, that'd be great.