Use of putCollection from an extension in Java

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
pep_castefa
Posts: 45
Joined: 01 Jun 2010, 10:31
Location: Barcelona, Spain

Use of putCollection from an extension in Java

Post by pep_castefa »

Hi... I'm trying to use putCollection from an extension in Java and everything seems to work fine from the server (at least it the extension doesn't crash), but from the client, in ActionScript 3 from a Flash Movie, I don't find the way to get the result:
In the server (extension in Java):

int[] status = someFunction(); //This function returns an Array of int
ActionscriptObject statusAO = new ActionscriptObject();
statusAO.putNumber("userId", user.getUserId());
//This next line is where I assign the collection. I use the Arrays.AsList
//function to convert the array to a Collection... After this line, when
//debugging, the statusAO contains the right information (I see it has
//the right information from the debug Window)
statusAO.putCollection("status", Arrays.asList(status));

//The rest of the code goes here (to send the information)

In the client (Flash with AS3):
1. I get the response and if I trace the "userId" variable, it is OK
2. I don't know how to get the array, collection or whatever... I have tried
trace(response.status) (it says 0)
trace(response.status as Array)
trace((response.status as Array)[0]) (it gives an error)

What am I doing wrong?

By the way... I know that, if in the server extension, convert the Array of integers to an ActionscriptObject and put the values there, it will work (I have seen the example in the documentation of how to pass an array of values this way)... but wanted to know if there was a more direct way of passing this information (if I use thas method, I will have to, in the server, loop all the Array, inserting each value in the ActionscriptObject)
Post Reply