2 Replies Latest reply on Jan 6, 2010 9:23 PM by flexy8

    Knowing when the callResponder's lastResult arrives?

    flexy8 Level 1

      is there a way to know when exactly the data arrived at the lastResult of the callResponder so that i would be able to execute another service call when the data arrives?

        • 1. Re: Knowing when the callResponder's lastResult arrives?
          chris.huston.t10 Level 3

          Yes, you can add an event listener that listens for the result event. This approach is much easier to debug than relying on lastResult.

           

          someServiceCall.addEventListener("result", resultHandler);

           

          private function resultHandler(evt:ResultEvent):void {

          var ac:ArrayCollection = evt.result; //Assign result data to whatever variable you need.

          callTheNextService();

          }

           

          Chris

          1 person found this helpful
          • 2. Re: Knowing when the callResponder's lastResult arrives?
            flexy8 Level 1

            Thanks for the idea. Now, how would I append or concatenate the results of each service call so that it will serve as my dataprovider on my List?

             

            here,s my code:

            <?xml version="1.0" encoding="utf-8"?>
            <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                 xmlns:s="library://ns.adobe.com/flex/spark" 
                 xmlns:mx="library://ns.adobe.com/flex/halo" xmlns:barangayservice="services.barangayservice.*">
                 <fx:Script>
                      <![CDATA[
                           import flash.events.MouseEvent;
                           
                           import mx.collections.ArrayCollection;
                           import mx.controls.Alert;
                           import mx.rpc.events.ResultEvent;
            
                           private var line:RegExp = /([a-zA-Z\-,'ñ0-9 ]+)/g;
                           
                           [Bindable]
                           private var resArr:ArrayCollection;
                           
                           protected function btnSearch_clickHandler(event:MouseEvent):void
                           {
                                var lineObj:Object = line.exec(taParse.text);
                                var lineArr:Array = [];
                                
                                while (lineObj != null)
                                {
                                     lineArr.push({vars:lineObj[1]});
                                     lineObj = line.exec(taParse.text);
                                }
                                
                                for(var l:uint = 0; l < lineArr.length; l++)
                                {
                                     getBarangaysByNameResult.token = barangayService.getBarangaysByName(lineArr[l].vars)
                                }
            
                           }
            
                           protected function barangayService_resultHandler(event:ResultEvent):void
                           {
                                resArr.addItem(event.result);
                           }
                      ]]>
                 </fx:Script>
                 <fx:Declarations>
                      <s:CallResponder id="getBarangaysByNameResult"/>
                      <barangayservice:BarangayService id="barangayService" result="barangayService_resultHandler(event)" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
                      <!-- Place non-visual elements (e.g., services, value objects) here -->
                 </fx:Declarations>
                 <s:Button x="146" y="169" label="Button" id="btnSearch" click="btnSearch_clickHandler(event)"/>
                 <s:List x="10" y="203" width="206" id="listSearch" dataProvider="{resArr}" labelField="barangay_name" height="129"></s:List>
                 <s:TextArea x="10" y="10" id="taParse" width="206"/>
                 <s:TextArea x="224" y="10" id="ta"/>
            </s:WindowedApplication>