AsyncToken, thats very cool. What part of the HTTP header does it use
to match up asyncronous calls?
Randy
On 9/27/07, Tracy Spratt <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
>
> Use a single HTTPService instance, and a single result handler.
>
> When you invoke send(), it returns an AsyncToken. This is a dynamic object
> to which you can add almost any property. I usually add a callid string
> property.
>
> Then in the result handler, I can access the callid property value, and
> process the result data accordingly.
>
> Tracy
>
> Snippets:
>
> Sample code using HTTPService, e4x, handler function to populate a list
> item.
> Also shows usage of AsyncToken.
>
> The DataGrid tag:
> <mx:DataGrid id="dg" dataProvider="{_xlcMyListData}" .../>
>
> The HTTPService tag:
> <mx:HTTPService id="service" resultFormat="e4x" result="onResult(event)"
> fault="..../>
>
> Script block declaration:
> import mx.rpc.Events.ResultEvent;
> [Bindable]private var _xlcMyListData:XMLListCollection;
>
> Invoke send:
> var oRequest:Object = new Object();
> oRequest.Arg1 = "value1";
> var callToken:AsyncToken = service.send(oRequest);
> token.callId = "myQuery1";
>
> Result Handler function:
> private function onResult(oEvent:ResultEvent):void {
> var xmlResult:XML = XML(event.result); //converts result Object to XML. can
> also use "as" operator
> var xlMyListData:XMLList = xmlResult.myListData; //depends on xml format,
> is row data
> _xlcMyListData = new XMLListCollection(xlMyListData); //wrap the XMLList in
> a collection
> trace(_xlcMyListData.toXMLString()); //so you can see exactly how to
> specify dataField or build labelFunction
> var callToken:AsyncToken = oEvent.token;
> var sCallId = callToken.callId; //"myQuery1"
> switch(sCallId) {
> case "myQuery1":
> doQuery2();
> break;
> ...
> }
> }//onResult
>
> ________________________________________
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Mansour Raad
> Sent: Thursday, September 27, 2007 3:32 PM
> To: [email protected]
> Subject: Re: [flexcoders] multiple http requests
>
> the player is limited by the number concurrent http to the _same_ domain of
> the browser (typically 2)
> If u target multiple domains at once - then u should be ok - so - create
> www.host[abcde...].com
>
> Mansour
> http://thunderheadxpler.blogspot.com
> :-)
>
> On Sep 27, 2007, at 11:35 AM, Randy Troppmann wrote:
>
> My application sometimes needs to make a flurry of http requests to a
> web service to populate some values. So it may send out 10 in a row
> quickly. Although the responses always come back in the order that
> they were requested, I am pretty sure that I cannot rely on this
> always being so. So I cache the calls and send them out one at a time
> and only when the previous response has been recieved. But this makes
> the mechanism pretty slow. Is there a better way or a pattern I should
> look at?
>
> - Randy
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
> Mansour
> http://thunderheadxpler.blogspot.com
> :-)
>
>