Passing Additional Var On Service Calls


Hey Guys,

If you want to preserve data which is request specifc, I have an example for you:


Lets say your using pureMVC and you have a user window, and you make a request by notification and you want to remember who made that call (like the mediator name or something).


One way is to add the data to the asyncToken, so


var token:AsyncToken = service.getUsers;

toke.preservedData = {bla:bla}


And after the result comes,  you extract it from the ResultEvent like:

trace( event.token.preservedData );




There is another way...


If you want to keep things more strictly typed, you can you a custom Responder:


So on the proxy, when you make the service call, you create a new instanse of a custom Responder, which holds additional parameters. and the code will look like this:





public class UserProxy extends Proxy {


public function getUsers(preservedData:Object):void{


          // 'service' is some remoteObject you define


var token:AsyncToken = service.getUsers();

          token.addResponder(new CustomResponder(handleUsersRecieved, handleServiceFault, preservedData));


private function handleUsersRecieved(event : ResultEvent, preservedData : Object):void {

            data = new UserVO(event.result.user);
private function handleServiceFault(event : FaultEvent, preservedData : Object):void{
       // Handle Fault








public class CustomResponder implements IResponder {
        private var _resultFunction:Function;
        private var _faultFunction:Function;
        private var _preservedData:Object;
        public function CustomResponder(resultFunction : Function, faultFunction : Function, preservedData : Object) {
            _resultFunction = resultFunction;
            _faultFunction = faultFunction;
            _preservedData= preservedData;

        public function result(event:Object):void {
  , event, _preservedData);
        public function fault(event:Object):void    {
  , event, _preservedData);


Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at