views:

439

answers:

1

There another person asking the same question here:

http://stackoverflow.com/questions/987130/how-do-i-call-a-remoteobject-method-from-actionscript

but what I need is to add more than one method to the RemoteObject.

Using the other question's example but adding one more method, how would this look in actionscript?

<mx:RemoteObject id="Server" destination="Server" source="gb.informaticasystems.Server" fault="handler_backendCommunicationFails(event)" >
  <mx:method name="executeQuery" result="handler_fetchDataRequestSuccess(event)"/>
  <mx:method name="getData" result="handler_getDataSuccess(event)"/>
</mx:RemoteObject>

Shua: Thanks a lot. You almost had it, with a couple of changes this is it:

var query:AsyncToken = ro.getQuery();
query.addResponder(new Responder(handler_fetchDataRequestSuccess, handler_fetchDataRequestFault) );

Needs both the result and fault methods in the Responder. And I've added multiple different methods using this.

+2  A: 
import mx.rpc.AsyncToken;
import mx.rpc.events.FaultEvent;
import mx.rpc.remoting.mxml.RemoteObject;

var ro:RemoteObject = new RemoteObject();
ro.destination = "Server";
ro.source = "gb.informaticasystems.Server";
ro.addEventListener( FaultEvent.FAULT, handler_backendCommunicationFails );


var query:AsyncToken = ro.executeQuery();
query.addResponder(new Responder( handler_fetchDataRequestSuccess ) );

var data:AsyncToken = ro.getData();
data.addResponder(new Responder( handler_getDataSuccess ) );
Shua
it might be ro.executeQuery.send(); and ro.getData.send();
Shua