Posted tagged ‘remoteobject’

How I write RemoteObject calls in Flex.

July 17, 2009

There are a few ways to handle responses after calling a method on one of your Flex RemoteObjects. You can define catch all result handlers in the MXML tag for your RemoteObject. You can also declare the methods you are going to call inside the MXML tag and set result handlers for each method.

The method I have found to work for me is to save the AsyncToken from a RemoteObject call and then add a responder to the token. I can do this in one line, saving me time in writing code. For example, suppose I am calling the getUsers method on my remote PHP UserManager class. I would write something like this.

AsyncToken(userManagerService.getUsers()).
addResponder(new mx.rpc.Responder(getUsers_result, fault));

I use the full path to mx.rpc.Responder since the Flex 3 compiler gives me warnings when I import mx.rpc.Responder and then use the short hand in MXML files.

How do you write your RemoteObject calls?

Advertisements