The tree does not know where in the xml node to look for the label.
Specifying the labelField tells it this.  The "@" indicates the data you
want is in an attribute.  So modify your Tree tag like this:

<mx:Tree left="0" top="0" bottom="0" right="0" id="TreeArtes" 
  dataProvider="{dadosTree.lastResult}"
  labelField="@label"/>

If your XML is more complex, or some nodes do not have a "label"(or
whatever) attribute, you can use a labelFunction().  Here is an example:
http://www.cflex.net/showFileDetails.cfm?ObjectID=564

Also, even though what you have is working, I advise against binding
directly to lastResult becaulse it is hard to debug, and you do not have
the opportunity to manipulate the data first.  I would declare a
[Bindable] instance variable of type XML, bind the tree to that, then
assign the xml data to that var in your result handler function.

Tracy

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of DANIEL CREDIDIO - INFORMATICA
Sent: Wednesday, October 03, 2007 11:56 AM
To: [email protected]
Subject: RES: [flexcoders] problem with Tree

Sorry alex, but can you explain it a little better, i'm quite noob when
it comes to XML things.
 

De: [email protected] [mailto:[EMAIL PROTECTED] Em
nome de Alex Harui
Enviada em: quarta-feira, 3 de outubro de 2007 12:41
Para: [email protected]
Assunto: RE: [flexcoders] problem with Tree
 
labelField="@label"
 

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Daniel Fernandes Credidio
Sent: Wednesday, October 03, 2007 8:25 AM
To: [email protected]
Subject: [flexcoders] problem with Tree
Hi all,

I'm starting to work with trees using an Httpservice to connect to the
bank and return me this XML: 

<Root>
<node label='Bla1'>
<node label='Bla2'>
<node label='Bla3'>
<node label="Bla4"/>
</node>
</node>
</node>
</Root>

I set the property resultformat as XML and its returning Ok the XML.
the problem is when i use it as a dataprovider. the tree doesen't
shows the right thing, it shows de XMLcode inteasted of the
name(Bla1,BLa2,BLa3 and bla4)

My Mxml is like this:

<mx:HTTPService id="dadosTree" url="criatree.asp" method="POST"
showBusyCursor="true" result="CriaTree();" resultFormat="xml"/>

<mx:Tree left="0" top="0" bottom="0" right="0" id="TreeArtes"
dataProvider="{dadosTree.lastResult}"/>

Please help me a i dont know wath i'm doing wrong
 

Reply via email to