4 Replies Latest reply on Dec 15, 2006 10:17 AM by FlightGuy

    to populate a tree with httpService

      i don't arrive to populate my tree with an httpService.
      Here is the code

      <mx:Tree width="30%" height="100%" id="arboChambre" labelField="@name" dataProvider="{restree.lastResult.chambres.type}" labelFunction="displayNodeName" />

      and the script in <mx:Script>
      private function displayNodeName( item:Object ) : String {
      var node:XML = XML(item);
      return node.@name;}

      the xml returned by httpservice
      <?xml version='1.0' encoding='utf-8' ?>
      <type name="standart">
      <chambre name="chambre1"/>
      <chambre name="chambre2"/>
      <chambre name="chambre3"/>
      <chambre name="chambre4"/>
      <chambre name="chambre5"/>
      <type name="superieur junior">
      <chambre name="chambre9"/>
      <chambre name="chambre10"/>

      And in my application i see only five icons files but not directory and not name of the files (or directory ....)
      Can you say me where is my mystake.
        • 1. Re: to populate a tree with httpService
          FlightGuy Level 1
          Please show us your HTTPService definition as well.
          • 2. Re: to populate a tree with httpService
            ntsiii Level 3
            Yes, specifically, is your resultFormat="e4x"?

            Also, binding directly to lastResult is hard to debug. I advise using a result handler function, where you can directly examine the xml structure.

            • 3. Re: to populate a tree with httpService
              MS! Level 1
              Thank for your answers and sorry for my english
              here is my httpservice definition in my file.mxml

              <mx:HTTPService id="restree" url=" http://lesite.com/index.php" useProxy="false" method="POST" >
              <mx:request xmlns="">

              If i don't want to use lasResult , i think that i must call the data in AS3 but it's difficult for me to understand the documentation in english ;I tried to use URLLoader but when i compile i have a lot of mistake.
              is it the good way to use URLLoader in <mx:script>???

              thank you
              • 4. Re: to populate a tree with httpService
                FlightGuy Level 1
                As Tracy mentioned, make sure you set the resultFormat of your HTTPService to "e4x".

                To assign the lastResult to a variable, do something like this:
                private var chambres:XML;

                private function setChambreData(event:ResultEvent):void{
                chambres = XML(event.result.chambres);

                <mx:HTTPService id="restree" url="..." resultFormat="e4x" result="setChambreData(event)"...