I see a few ways to do this. The key to all of them is using AsyncToken.
You could add a callback parameter to your components send() function. If you use a function, then you can place a callback function directly in the AsyncToken(Responder?) and have the result handler execute the function You could use a string that is the name of the callback function, put that in the AsyncToken, and in the handler, like you have done, use bracket notation to get a reference to and execute the function. You could pass in a string use a string that identifies the call, then have your component dispatch an event on result. Either use a custom event that contains the result data and call identifier, or expose the "lastResult" and "callId" in public properties. Have the handler for the components result event use that data to execute whatever you need. You can mix and match these approaches as well. Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of markgoldin_2000 Sent: Friday, October 10, 2008 8:12 AM To: [email protected] Subject: [flexcoders] Re: Question about HTTPService and callbacks Anybody, please, any idea? --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "markgoldin_2000" <[EMAIL PROTECTED]> wrote: > > I am building a common library to shre it between diffrent projects. > First of all it will be used for data access. I am using HTTPService > for all my data needs. Data retrival is a generic operaton, but data > processing is not. I need to provide a custom callback function for > each service.send(parameters) result. I am defining a callback for > service itself: > service.addEventListener("result", httpResult); > > private function httpResult(event:ResultEvent):void > { > var result:Object = event.result; > var xmlResult:XML = XML(result); > > // here I need to call a function(xmlResult) that is specified by a > data requestor which is in a diffrent project. > } > I was able to acoomplish (well, sort of) that by having HTTPService > code and custom callbacks code in one package: > private function httpResult(event:ResultEvent):void > { > var result:Object = event.result; > var xmlResult:XML = XML(result); > this[CallbackToRun](xmlResult); > } > where CallbackToRun is defined prior the call. > > Any idea how to do that? > > Thanks >

