0 Replies Latest reply on Nov 18, 2007 8:48 AM by curtkauf

    Load web service into ArrayCollection

    curtkauf
      I can't seem to get a .Net wed service to load into an ArrayCollection. There is something I don't understand. Her is my code..

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      creationComplete="initApp()" backgroundColor="#FFFFFF">
      <mx:Script>
      <![CDATA[
      import mx.charts.events.ChartItemEvent;

      import mx.collections.ArrayCollection;
      import mx.charts.HitData;
      import mx.controls.Alert;

      [Bindable]
      private var serviceRevenue:ArrayCollection;

      private function runService():void{
      this.wsWeeklyReports.DataForWeek.send();
      serviceRevenue = new ArrayCollection(this.wsWeeklyReports.DataForWeek.lastResult);
      }

      ]]>
      </mx:Script>
      <mx:WebService id="wsWeeklyReports"
      wsdl=" http://localhost:1602/CS_Webservice/WeeklyReports.asmx?wsdl" useProxy="false"
      fault="Alert.show(event.fault.faultString), 'Error'">
      <!-- this operation returns the revenu by service by date-->
      <mx:operation name="DataForWeek">
      <mx:request>
      <dteWEDate>{this.dteWEDate.selectedDate.toDateString()}</dteWEDate>
      <strType>{this.lblType.text}</strType>
      </mx:request>
      </mx:operation>
      </mx:WebService>

      <mx:ApplicationControlBar width="100%" fillColors="[#460064, #008484]">
      <mx:DateField id="dteWEDate"/>
      <mx:Button label="Run" id="btnRun" click="{runService()}"/>
      <mx:Label text="R" id="lblType"/>
      </mx:ApplicationControlBar>

      <mx:Panel title="Revenue by Date" width="100%" height="100%"
      paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">

      <mx:ColumnChart id="columnChart"
      height="100%" width="100%"
      paddingLeft="5"
      paddingRight="5"
      showDataTips="true"
      dataProvider="{serviceRevenue}">
      <mx:horizontalAxis>
      <mx:CategoryAxis categoryField="date"/>
      </mx:horizontalAxis>
      <mx:verticalAxis>
      <mx:LinearAxis minimum="1" />
      </mx:verticalAxis>
      <mx:series>
      <mx:ColumnSeries xField="date" yField="total" displayName="date">
      </mx:ColumnSeries>
      </mx:series>
      </mx:ColumnChart>


      </mx:Panel>
      </mx:Application>

      If I just call the web service and set the chart dataprovider to the web services last result all works well. But my guess is down the road I will find that the ArrayCollection is the right way to go and is more versatile. Any help would be appreciated...I think this is a basic thing...and I need to understand what I'm doing wrong. Thanks so much!

      Thanks!
      curtkauf