How to pass an array in AS3 to an array in php?
I have the following array as3 example:
var arrayDefinitionsargsAmfPhp:Array = new Array();
arrayDefinitionsargsAmfPh开发者_运维技巧p['tabela'] = "controls";
arrayDefinitionsargsAmfPhp['width'] = "100";
sending him to the remote object for php, example:
async = bridge.getOperation(amfphpFunction).send(arrayDefinitionsargsAmfPhp);
In php I try to get the array like this:
function retornamenu($tableInBd)
{
$arr = array($tableInBd);
$tableInBdname = $arr['tabela'];
$widthInBdname = $arr['width'];
But unfortunately these variables $tableInBdname and $widthInBdname not come to php, can someone help me with an example?
Thank already
You can send by sumbitting the values as URLVariables/ ..
var variables:URLVariables = new URLVariables();
variables.NAME = "Hello";
variables.EMAIL = "Hello@Hello.com"
var request:URLRequest = new URLRequest("sentFromFlex.php");
request.data = variables;
request.method = URLRequestMethod.POST;
sendToURL(urlrequest);
and in the PHP, you can get these variables in the $_POST array..
echo $_POST['NAME'];
echo $_POST['EMAIL'];
[Bindable] public var rows2:Object = new Object();
Hold all the data in rows2 Object and dispatch it to PHP.
rows2=Application.application.whateverStuff;
<mate:eventProperties>
<mate:EventProperties rows2="{rows2}"/>
</mate:eventProperties>
Now in the Event properties, you get the rows2 and which you send to PHP via Remoting.
public function yourPHP($data)
{
//return print_r($data,true);
if(!$data || !is_array($data)|| !sizeof($data)){throw new Exception("No data sent.".(is_object($data)?"y":"n"));}
//throw new Exception(print_r($data,true));
array_shift($data);//get rid of the first row
foreach($data as $row)
{
Now perform your manipulation here.
}
}
the answer is ok, the solution is:
PHP
function retornamenu($tableInBd)
{
$tableInBdname = $tableInBd['tabela'];
$mensagem = $tableInBd['mensagem'];
AS3
var arrayDefinitionsargsAmfPhp:Array = new Array();
arrayDefinitionsargsAmfPhp['tabela'] = "controls";
arrayDefinitionsargsAmfPhp['mensagem'] = "este sao dados que vierem via array do as3";
async = bridge.getOperation(amfphpFunction).send(arrayDefinitionsargsAmfPhp);
thanks
精彩评论