1 Reply Latest reply on Nov 21, 2006 6:01 AM by Garenne

    From HTTPService to ArrayCollection

      Hi all,

      I've been practicing on Flex for several weeks, and I really appreciate it. I especially use it to display data from MySQL BD. One thing I can't clearly find out is how to pass data from an XML file (acessed by an HTTPService) to an ArrayCollection. I've tried several methods, it never works.

      Here's my last try :

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

      import mx.collections.ArrayCollection;
      import mx.utils.ArrayUtil;

      <mx:HTTPService id="Liste_XML" url=" http://www.hereismyXMLfile.com/file.php" useProxy="false" method="POST"/>

      <mx:ArrayCollection id="arrayfilms" source="{mx.utils.ArrayUtil.toArray(Liste_XML.lastResult.liste.affiche)}" />

      <mx:DataGrid dataProvider="{arrayfilms}" creationComplete="Liste_XML.send()" width="500"/>

      The datagrid doesn't display anything at all.
      Does this code look correct ? I've seen other methods to "fill" an ArrayCollection using event, but was not able to make it work... :(

      Thanks by advance for your help,
      Garenne ./.
        • 1. Re: From HTTPService to ArrayCollection
          Garenne Level 1
          Hi, this post to say i found a solution, using ResultEvent method :

          import mx.collections.ArrayCollection;
          import mx.rpc.events.ResultEvent;

          private var arrayfilms:ArrayCollection;
          private function resultHandler(event:ResultEvent):void {
          arrayfilms = event.result.liste.affiche;

          <mx:HTTPService id="ListeXML" url=" http://www.hereismyXMLfile.com/file.php" result="resultHandler(event)"/>

          So Admin can consider this topic is closed. Thank you.