Search code examples
javaactionscript-3red5netconnection

Actionscript 3 Array to Java ArrayList using Red5


I'm creating an array in AS3 and sending it using a NetConnection to a red5 server as so:

var data:Array = new Array();

data.push("getTest");

NC.call("getUsers", new Responder(onSuccess, onFail), data);

And on the server side:

public Object getUsers(Object[] params) {

        logger.warn("params = "+params);
        logger.warn(params[0]);
        List<Object> u = (ArrayList<Object>)params[0];
        logger.warn(u.get(0));

        return params;
}

However the line:

List<Object> u = (ArrayList<Object>)params[0];

Seams to be failing for some reason.


Solution

  • I'm not really familiar with Java, but I think I've had a similar remoting issue with AMFPHP when trying to pass in an array of parameters, but not have it read as an array on the server side. My solution was to use (in Actionscript) the Function.apply method. In your case it would look something like:

    var data:Array = new Array();
    
    data.push("getTest");
    
    NC.call.apply(this, ["getUsers", new Responder(onSuccess, onFail)].concat(data));
    

    Could maybe work for you too? Hope it helps.