How I write RemoteObject calls in Flex.

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
Explore posts in the same categories: Flex

Tags: , , , ,

You can comment below, or link to this permanent URL from your own site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: