Jul 14 2008
Cairngorm and Remote Object
I have had opportunity to use Cairngorm with Webservices, Httpservice and Remote Object as well. I had some difficulty passing variables to the amfphp backend but ultimately resolved it. here is how,
product = event.data.product;
responderObj = event.data.responderObj;
productId = product.products_id;
var service:RemoteObject = ServiceLocator.getInstance().getRemoteObject("getProducts");
var operation:Operation = service.getOperation("get_colors") as Operation;
//this method of sending arguments wasn't working, it was sending undefined.
//var dataArray:Array = new Array({productId:"93"});
//operation.argumentNames = dataArray;
var token:AsyncToken = operation.send(productId);
token.addResponder(this);
}
For some reason operation.argumentNames i thought would take the array and then send the objects in this array as variables, but it was sending undefined as the value for the variable.
I resolved the problem by sending the variables in send function and i am sure you can send more than one variable in the send function.
Hello Nayan,
If you just set the operation.arguments property with a simple array, and take the productID parameter out of the send(), then this will work for this and other examples of more than one parameter. In your example above – if you change the line
var dataArray:Array = new Array ({productId:”93″});
to
var dataArray:Array = new Array (“93”);
then add:
operation.arguments = dataArray;
and then call send…
var token:AsyncToken = operation.send();
you should find that things work as you would want them to… and you could add more elements to the array if there where more parameters etc.
All the best,
Mick
hi mick,
thanks for your feedback, as always there are different ways of doing the same thing in flash :), the send takes multiple paramaters as well.
operation.send(first,second,third);
this works great as well.
nayan