Defining a RemoteObject in ActionScript without -services compiler flag

I ran across a problem today trying to define a RemoteObject (mx.rpc.remoting.mxml.RemoteObject) in ActionScript instead of a services-config.xml file.

It seems like it would be fairly straightforward

 var myRo:RemoteObject = new RemoteObject();
 myRo.source = "amf_tests.HelloWorld";
 myRo.destination = "amfphp";
 myRo.endpoint = "/amfphp/gateway.php";

but, alas, I found that endpoint isn’t a property, though it looks like it might be in the future. It isn’t even a readily accessible class. You need to build a channelset, add a channel, and then pass a url (and id) to the channel to specify the endpoint. Something like this:

 myRo.channelSet(new ChannelSet().addChannel(new AMFChannel("my_amfphp", "/amfphp/gateway.php")));

The above is equivalent to the following services-config.xml (I think):

<?xml version="1.0" encoding="UTF-8"?>
  <service id="amfphp-flashremoting-service" class="" messageTypes="flex.messaging.messages.RemotingMessage">
   <destination id="amfphp">
     <channel ref="my_amfphp"/>
  <channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel">
   <endpoint uri="/amfphp/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>

This explains it better than me.

One thought on “Defining a RemoteObject in ActionScript without -services compiler flag

  1. It looks like you can get by with setting ro.endpoint and not messing with the channels. Don’t know what wasn’t working for me before.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s