Send Array To client

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

Moderators: Lapo, Bax

Post Reply
nikolaiko
Posts: 13
Joined: 30 Mar 2011, 10:40

Send Array To client

Post by nikolaiko »

Hi, everyone.
I faced a problem sending Array of Actionscriptobject to client.
I using:

Code: Select all

ActionscriptObject ResponseObj = new ActionscriptObject();
LinkedList<ActionscriptObject> a = new LinkedList<ActionscriptObject>();

for(i=0;i<aCellsToOpen.size();i++)
{
      a.add(aCellsToOpen.get(i));
       trace(String.valueOf(aCellsToOpen.get(i).get("x")));
       trace(String.valueOf(aCellsToOpen.get(i).get("y")));
       trace(String.valueOf(aCellsToOpen.get(i).get("val")));
}                  

    ResponseObj.putNumber("idGame", size);
    ResponseObj.putNumber("idUser", id);
    ResponseObj.putNumber("action", iAction);
    ResponseObj.putCollection("cell_arr", a);
     ResponseObj.putNumber("idUserNext", 3);

  aRecipeends.add(user.getChannel());

  sendResponse(ResponseObj, -1, null, aRecipeends);
aCellsToOpen - it is a ArrayList of Actionscriptobject's in cycle I just moving all elements to 'a' variable that implements Collection interface.
But on the client I get only

Code: Select all

<msg t='xt'><body action='xtRes' r='-1'><![CDATA[<dataObj><var n='idUserNext' t='n'>3</var><var n='idGame' t='n'>1</var>[b]<obj o='cell_arr' t='a'><obj o='0' t='a'></obj></obj>[/b]<var n='action' t='n'>1001</var><var n='idUser' t='n'>1</var></dataObj>]]></body></msg>, (len: 260)
And here is function for working with array on client:

Code: Select all

private function evExt(pEvent:SFSEvent):void
		{
			var obj:Object = pEvent.params.dataObj;
			if (obj["cell_arr"] != null)
			{
				trace("celll:" + obj["cell_arr"][0]);
			}
			
		}
But it trace nothing.
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

It looks like it should work.

Are all your x, y and val of type int, boolean, double, String or ActionscriptObject?
Smartfox's forum is my daily newspaper.
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

Your aCellsToOpen.get(i) would need to be an ActionscriptObject for this to work.
Smartfox's forum is my daily newspaper.
nikolaiko
Posts: 13
Joined: 30 Mar 2011, 10:40

Post by nikolaiko »

Thanks for answer. I found a reason. In place where I create aCellsToOpenArray, I create a elements (fields x and y) for it using put command. I changed it to putNumber and it helped. It such a big difference between those commands?
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

Looks like it :?
Smartfox's forum is my daily newspaper.
Post Reply