Reputation: 993
I try to pass an Arraycollection to php. To do that, I use this function:
public function arrayCollectionToString( myArrayCollection:ArrayCollection ):String
{
var collStr:String = new String();
for each( var obj:Object in myArrayCollection )
{
collStr += "[";
var i:int=0;
for each( var obj2:Object in obj )
{ i++;
if(i==1){
collStr += obj2.toString();
}else{
collStr +=", "+ obj2.toString();
}
}
collStr += "]";
}
return collStr;
}
This function transform arraycollection in string, but how to know in witch order key appear ? Or if it's not possible, how transmit keyname to php and split the string in php script to transform string into array? Thanks
Upvotes: 0
Views: 601
Reputation: 993
I found a solution with including array ok key in my function:
var keys:Array = ["idLien", "codeRDV", "nomRDV"];
var sGrpRDV:String = new ArrayFunction().arrayCollectionToString2(DP_GRP_RDV_D,keys);
public function arrayCollectionToString2( myArrayCollection:ArrayCollection, myOrderKey:Array ):String
{
var collStr:String = new String();
for each( var obj:Object in myArrayCollection )
{
collStr += "[";
var i:int=0;
for each (var k:String in myOrderKey)
{
i++;
if(i==1){
collStr += obj[k];
}else{
collStr +=", "+ obj[k];
}
}
collStr += "]";
}
return collStr;
}
Upvotes: 0
Reputation: 1139
The best method to exchange data between flash app and php script is using json. You can see it here for more detail: http://digitalmemo.neobie.net/2009/10/22/passing-object-from-flash-as3-to-php/ and here http://digitalmemo.neobie.net/2009/10/22/passing-object-from-flash-as3-to-php/. You convert your flash native array to json using as3corelib (http://code.google.com/p/as3corelib/) and handle json by json_decode() method in php.
Upvotes: 3