Your code is properly traversing all nodes, including the root node. But when you recursively call showList(item.children()), the first thing that happens is that you set

 

    txtResults.txt = "";

 

which wipes out the previous text produced from the root node. I found what the problem was by inserting trace() statements rather than just looking at the final txtResults.txt.

 

The debugger in FlexBuilder 2 also makes it easy to step through your code one line at a time to determine whether it is processing the root node or not. (Shameless plug for spending money on FlexBuidler... it would have saved you 7 hours!)

 

- Gordon

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Rick Root
Sent: Wednesday, August 09, 2006 1:18 PM
To: [email protected]
Subject: Re: [flexcoders] accessing item data in an XMLList

 

ping... 7 hours later I haven't come up with a solution.. anyone?

I suppose I could send the whole XMLList object to coldfusion as a
string and have Coldfusion parse it, but that seems like an unnecessary
use of network bandwidth when all I really want are the labels compiled
into an array and sent.

Rick

Rick Root wrote:
>
> So far, I've been unable to find examples of using a tree control and
> sending its data to a web service, remote object, etc. Lots of example
> code on using the tree control, enabling drag and drop, putting
> different kidns of data INTO the tree control- but nothing about getting
> the data out of it.
>
> My tree control is driven by an XMLList object. What i'd like to do is
> get an array of all the labels for each node, but I'm not having any luck.
>
> Here are my sample XMLList objects:
>
> <mx:XMLList id="treeData1">
> <node label="One item with subitem">
> <node label="Subitem"/>
> </node>
> </mx:XMLList>
> <mx:XMLList id="treeData2">
> <node label="One Item Only"/>
> </mx:XMLList>
>
> and here is my function that shows me the items in the tree:
>
> private function showList(list):void
> {
> var item:XML;
> txtResults.text = '';
> for each(item in list)
> {
> txtResults.text += "item: " + item.attribute('label') + '\n';
> if (item.elements().length() > 0)
> {
> showList(item.children());
> }
> }
> }
>
> Unfortunately, it doesn't seem to return the label on the root node.
>
> I've also tried adding the following line above the for loop to no avail:
>
> txtResults += list.attribute('label');
>
> Can someone point me in the right direction?

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to