First, Flex is converting the xml into an Object.  To change this to keep it xml, set resultFormat="xml"

Second, for hierarchical data providers use "selectedNode", not "selectedItem"."

Third, "var node:Object=event.target.selectedNode.attributes;" is not returning a node, it is probably returning an array of attributes.  I don't think that is what you want.

Fourth, use "selectedLabel = node.getProperty("label");"

See the "TreeDataProvider" API in the livedocs:
http://livedocs.macromedia.com/flex/15/asdocs_en/mx/controls/treeclasses/TreeDataProvider.html

Tracy

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Alin DICU
Sent: Friday, May 12, 2006 8:07 AM
To: [email protected]
Subject: Re: [flexcoders] problems accessing a tree with xml from a HTTPService

---------------------------the httpservice
code---------------------------------------

    <mx:HTTPService
        id="treeHttpSrv"
        concurrency="multiple"
        method="GET"
        url="" href="http://localhost:8084/FlexXMLServer/XMLTreeElementsServlet">http://localhost:8084/FlexXMLServer/XMLTreeElementsServlet"
        showBusyCursor="true"
        fault="alert(event.fault.faultstring);"/>

---------------------------- the UI tree code
-----------------------------------------
<mx:Tree id="albumsTree" dataProvider="{treeHttpSrv.result}"
width="100%" change="showTreeSelection(event)" height="100%"/>
---------------------------- the received XML
---------------------------------------

        <node label="Albums" data="" type="root">
            <node label="BMW" data="" type="album">
                <node label="BMW 325ci 1994"
data="" href="http://localhost:8080/FlexXMLServer/Photos/BMW/BMW">http://localhost:8080/FlexXMLServer/Photos/BMW/BMW 325ci
1994.jpeg" type="photo"/>
                <node label="BMW E65 Schnitzer"
data="" href="http://localhost:8080/FlexXMLServer/Photos/BMW/BMW">http://localhost:8080/FlexXMLServer/Photos/BMW/BMW E65
Schnitzer.jpeg" type="photo"/>
            </node>
            <node label="Mercedes" data="" type="album">
                <node label="Mercedes ML back"
data="" href="http://localhost:8080/FlexXMLServer/Photos/Mercedes/Mercedes">http://localhost:8080/FlexXMLServer/Photos/Mercedes/Mercedes ML
back.jpg" type="photo"/>
                <node label="Mercedes ML front"
data="" href="http://localhost:8080/FlexXMLServer/Photos/Mercedes/Mercedes">http://localhost:8080/FlexXMLServer/Photos/Mercedes/Mercedes ML
front.jpg" type="photo"/>
            </node>
        </node>

----------------------------- the accesing attributes method
---------------------------

           function showTreeSelection(event)
           {
                var node:Object=event.target.selectedItem.attributes;
                selectedLabel = node.label;
                selectedData = node.data;
                nodeType = node.type;
                //alert(selectedLabel + " " + selectedData + " " +
nodeType);
              
                switch(nodeType)
                {
                    case root:
                        var params = new Object();
                        params.param1 = initListe;      
                                         
                          rechTreeHttpSrv.send(params);
                      
                        break;
                    case album:
                        var params = new Object();
                        params.param1 = rechercherSelonAlbum;
                        params.param2 = selectedLabel;  
                          
                        rechTreeHttpSrv.send(params);
                                          
                        break;
                    case photo:
                        showPopUp(selectedLabel);
                        break;
                    default:
                        ;
                }
           }

Right now, I'm using the xecat xml, only that it is statically put into
the .mxml page.

Thanks,

Tracy Spratt a écrit :
> I do this regularly.
>
> How are you attempting to access the attributes?
>
> Tracy
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Alin DICU
> Sent: Thursday, May 11, 2006 10:03 AM
> To: [email protected]
> Subject: [flexcoders] problems accessing a tree with xml from a
> HTTPService
>
> Hi,
>
> I use the following xml to create a tree that is displayed:
>
> <node label="Albums">
>     <node label="BMW">
>         <node label="BMW 325ci 1994"
> data="" href="http://localhost:8080/FlexXMLServer/Photos/BMW/BMW">http://localhost:8080/FlexXMLServer/Photos/BMW/BMW 325ci
> 1994.jpeg"/>
>         <node label="BMW E65 Schnitzer"
> data="" href="http://localhost:8080/FlexXMLServer/Photos/BMW/BMW">http://localhost:8080/FlexXMLServer/Photos/BMW/BMW E65
> Schnitzer.jpeg"/>
>     </node>
>     <node label="Mercedes">
>         <node label="Mercedes ML back"
> data="" href="http://localhost:8080/FlexXMLServer/Photos/Mercedes/Mercedes">http://localhost:8080/FlexXMLServer/Photos/Mercedes/Mercedes ML
> back.jpg"/>
>         <node label="Mercedes ML front"
> data="" href="http://localhost:8080/FlexXMLServer/Photos/Mercedes/Mercedes">http://localhost:8080/FlexXMLServer/Photos/Mercedes/Mercedes ML
> front.jpg"/>
>     </node>
> </node>
>
> The problem comes when I get this data from HTTPService or from a file.
> When I do this I cannot access the "label" and "data" attributes
> of the selected node.
>
> Has anyone dealed with this problem?
>
> Thanks,
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
> --
> 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
> <http://groups.yahoo.com/gads?t=ms&k=Web+site+design+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=L-4QTvxB_quFDtMyhrQaHQ>
>       Computer software development
> <http://groups.yahoo.com/gads?t=ms&k=Computer+software+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=lvQjSRfQDfWudJSe1lLjHw>
>       Software design and development
> <http://groups.yahoo.com/gads?t=ms&k=Software+design+and+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=1pMBCdo3DsJbuU9AEmO1oQ>
>
> Macromedia flex
> <http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=OO6nPIrz7_EpZI36cYzBjw>
>       Software development best practice
> <http://groups.yahoo.com/gads?t=ms&k=Software+development+best+practice&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=f89quyyulIDsnABLD6IXIw>
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
>     *  Visit your group "flexcoders
>       <http://groups.yahoo.com/group/flexcoders>" on the web.
>       
>     *  To unsubscribe from this group, send an email to:
>        [EMAIL PROTECTED]
>       <mailto:[EMAIL PROTECTED]>
>       
>     *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>




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











--
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