8 Replies Latest reply on Jun 14, 2006 1:37 PM by ntsiii

    Question about get web service result in actionscript and convert data format

    TigerLittle
      Hi, All

      I have question about how to get dataset from web services and put it in tree structure. I have 2 questions about this:
      1, How can I get data correctly in actionscript?

      I have no problem to get data by
      <mx:ArrayCollection id="acFolder" source="{mx.utils.ArrayUtil.toArray(MyGServices.getFolder.lastResult)}" />
      And display in datagrid.

      But when I try to use
      public function handleFolderContents(event:mx.rpc.events.ResultEvent):void{
      arData=mx.utils.ArrayUtil.toArray(event.result);
      acData=new ArrayCollection(arData);
      input.text=acData.getItemAt(0).id;
      }
      Seems I can’t get data, it always say:
      TypeError: Error #1009: Cannot access a property or method of a null object reference.


      2, how to convert data format
      I get data from web service and want to convert it to tree structure, as mention below:
      I get:
      <Array>
      <id>111</id>
      <Name>Production1</Name>
      </Array>
      <Array>
      <id>222</id>
      <Name>Production2</Name>
      </Array>

      Convert to:
      <mx:XMLList id="treeData">
      <node>
      <node label="Production1" data="111">
      <node label="Production2" data="222"/>
      </node>
      </node>
      </mx:XMLList>

      Please help me.

      Thanks.