3 Replies Latest reply on Aug 7, 2006 5:51 PM by ntsiii

    dynamic tree

    stfal
      Hi,
      I am new to Flex. I am trying to build a Tree component with XML content that comes from an http request. I am assuming that I need to use the HTTPService component similar to what I have below, but I can't figure out the syntax. Can someone show me some code for that?

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" initialize="xmlFeed.send()">
      <mx:HTTPService id="xmlFeed" url=" http://myserver/xmlservlet" resultFormat="xml"/>
      <mx:Tree id="firstList" dataProvider="xmlFeed.lastResult" ....>
      </mx:Application>

      Thanks,
      Steve
        • 1. Re: dynamic tree
          ntsiii Level 3
          Ok, you have two possible problem points here, the data retrieval, and the tree display, so you need to do one at a time.

          First, hard code a little of the xml that you are expecting from the HTTPService. See the example in the flex Explorer:
          http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html
          then go to Visual Components, General controls, Tree. copy the code and get it to work on you machine.

          Then change the hardcoded xml in the example to be the same as the xml you are getting from the HTTPService.

          When all that is working, post back ans we will work on the HTTPService call and the dataProvider reference.

          Tracy
          • 2. Re: dynamic tree
            stfal Level 1
            Thanks Tracy ... I was able to get it to work bsed on some some of the examples you pointed me to. Turns out I didn't need to use the HTTPService component, but was able to do it as follows:

            <mx:XML id="treeModel" source=" http://myserver/xmlservlet"/>
            <mx:Tree id="xmlTree" height="200" width="200"
            dataProvider="{treeModel}" />

            Steve
            • 3. Re: dynamic tree
              ntsiii Level 3
              Sure. Be aware that that syntax is a compile time load of the xml.

              If you want to load it at runtime (initial load performance?) or change it at run time, you will need HTTPService.

              Tracy