Jul 14 2008

Cairngorm and Remote Object

Published by at 10:33 pm under AS 3.0,Flex

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,

public function execute(event:CairngormEvent):void {
           
    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.

2 responses so far

2 Responses to “Cairngorm and Remote Object”

  1. Mick Powellon 29 Oct 2008 at 3:58 pm

    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

  2. Nayanon 29 Oct 2008 at 5:36 pm

    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

Trackback URI | Comments RSS

Leave a Reply