4 Replies Latest reply on Mar 2, 2007 5:34 PM by tspratt

    Binding lastResult as e4x to XMLListCollection

    Xygar
      I'm trying to bind the results of an HTTPService to an XMLListCollection, which I then use to populate a Tree. I can sort of get it to work, but according to the documentation, as long as the resultFormat is "e4x" the lastResult object should be an xmlList. Is this correct? Here's a section of my code:

      <mx:HTTPService id="rawBookData" resultFormat="e4x" result="onBookData(event);">
      </mx:HTTPService>

      <mx:XMLListCollection id="bookPages" source="{rawBookData.lastResult}">
      </mx:XMLListCollection>

      ...

      <mx:Tree id="contentTree" width="100%" height="100%" showRoot="true" dataProvider="{bookPages}" labelField="@title">
      </mx:Tree>

      However, if I try and compile this, I get an error message: "Error: Implicit coercion of a value with static type Object to a possibly unrelated type XMLList."

      If I use rawBookData.lastResult.* then I get everything beneath the root node, but not the root node itself, in the tree. I'm still quite new to Flex, so any help would be appreciated. Here is my XML:

      <node id="31" type="Book" isBranch="true" title="Forensic Science">
      <node id="519" type="Section" isBranch="true" title="Session 1">
      <node id="520" type="Page" isBranch="true" title="Page 1"/>
      </node>
      <node id="522" type="Section" isBranch="true" title="Session 2">
      <node id="523" type="Page" isBranch="true" title="Page 1"/>
      </node>
      <node id="525" type="Section" isBranch="true" title="Session 3">
      <node id="526" type="Page" isBranch="true" title="Page 1"/>
      </node>
      <node id="528" type="Section" isBranch="true" title="Session 4">
      <node id="529" type="Page" isBranch="true" title="Page 1"/>
      </node>
      <node id="531" type="Section" isBranch="true" title="Session 5">
      <node id="532" type="Page" isBranch="true" title="Page 1"/>
      </node>
      <node id="534" type="Section" isBranch="true" title="Session 6">
      <node id="535" type="Page" isBranch="true" title="Page 1"/>
      </node>
      <node id="537" type="Section" isBranch="true" title="Session 7">
      <node id="538" type="Page" isBranch="true" title="Page 1"/>
      </node>
      </node>