1 Reply Latest reply on Jul 19, 2006 5:02 PM by dishmael

    Binding XML to ArrayCollection

    dishmael
      I'm completely stumped. I had an application that worked in Flex Builder 2 beta 3 that took XML results from an HTTPService and binded them to an ArrayCollection. I could then use the ArrayCollection as my dataProvider for a DataGrid. This methodology allowed me to do a pre-sort on the data by sorting the ArrayCollection. I recently upgraded to the latest release of Flex Builder 2 and now it appears the application does not work. It says I need to cast the HTTPService results as an Array:

      <mx:ArrayCollection id="myAC" source="{ArrayUtil.toArray(service.lastResult.resultset.result)}" />

      When I do this, the application builds but now the DataGrid doesn't populate. I've tried everything I can possibly think of to get this working. Can someone show me a working example where XML returned from an HTTPService is bound to a collection which is then bound to a DataGrid?
        • 1. Re: Binding XML to ArrayCollection
          dishmael Level 1
          I figured it out. I have no clue why but I had to do the binding in AS:

          [Bindable]
          private var xml:ArrayCollection = null;

          private function bind(event:ResultEvent):void {
          xml = event.result.resultset.result;
          }

          Then for the HTTPService:

          <mx:HTTPService result="bind(event)" url=" http://localhost"/>

          Now everything is working correctly; I can sort, filter, etc. on the ArrayCollection.