0 Replies Latest reply on Oct 2, 2010 5:30 AM by sgfone

    How do I initialize an array after getting xml data via httpservice?


      I am having a problem trying to initialize an array with data from an external xml file obtained via httpservice.  Any help/direction would be much appreciated.  I am using Flex 4 (Flash Builder 4).

      Here is my xml file (partial):

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
              <icdcodedanddesc>00 PROCEDURES AND INTERVENT</icdcodedanddesc>
              <icdcodedanddesc>00.0 THERAPEUTIC ULTRASOUND</icdcodedanddesc>
              <icdcodedanddesc>00.01 THERAPEUTIC US VESSELS H</icdcodedanddesc>
              <icdcodedanddesc>00.02 THERAPEUTIC ULTRASOUND O</icdcodedanddesc>



      Here is my http service call:

      <s:HTTPService id="icdcodeservice" url="ICD9V2MergeNumAndDescNotAllCodes.xml"
                             result="icdcodesService_resultHandler(event)" showBusyCursor="true"  />

      (I have tried resultFormat using object, array, xml).


      I am using this following Tour de Flex example as the base -http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500

      and updating it with the httpservice call and result handler.  But I cannot get the data to appear - I get [object Object] instead.  In my result handler code  I use "icdcodesar = new Array(event.result.Root.Row);"  and then "icdcodesar.refresh();".


      The key question is: How to I get data from an external xml file into an array without getting [object Object] when referencing the array entries.  Thanks much!


      (Tour de Flex example at http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500  follows)

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"  
              @namespace s "library://ns.adobe.com/flex/spark";
              @namespace mx "library://ns.adobe.com/flex/mx";
              @namespace local "*";
              s|Label {
                  color: #000000;
                  import mx.collections.ArrayCollection;
                  private var names:ArrayCollection = new ArrayCollection( 
                      ["John Smith", "Jane Doe", "Paul Dupont", "Liz Jones", "Marie Taylor"]);
                  private function searchName(item:Object):Boolean
                      return item.toLowerCase().search(searchBox.text) != -1;
                  private function textChangeHandler():void
                      names.filterFunction = searchName;
                      searchBox.dataProvider = names;
                  private function itemSelectedHandler(event:SearchBoxEvent):void
                      fullName.text = event.item as String;    
              <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" />
          <s:Panel title="Components Samples"
                   width="600" height="100%"
                  <s:HorizontalLayout horizontalAlign="center" 
                                      paddingLeft="10" paddingRight="10" 
                                      paddingTop="10" paddingBottom="10"/>
              <s:HGroup >
                  <s:Label text="Type a few characters to search:" />
                  <local:SearchBox id="searchBox" textChange="textChangeHandler()" itemSelected="itemSelectedHandler(event)"/>
              <mx:FormItem label="You selected:" >
                  <s:TextInput id="fullName"/>