Using Zend_Amf with Flex

We have to do the following from flex script
1. Setting a target url
There are different ways to do it and I share one of them.
We need to create service-config.xml and save that in the project src folder.
Ex:
services-config
services
service id="amfphp-flashremoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage"
destination id="flex_amf"
channels
channel ref="my-zend"
channels
properties
source*Flex Compiler settings.
Ex:-locale en_US -services service-config.xml
3. In your mxml file add RemoteObject component
Ex:

In this source is the class name that you are using in PHP and destination refers to destination tab in the service-config.xml file
4. Create a button to execute the click function and in that call the function you need to execute in the class file.
zendRemoteObject.functionName(parameters)
5. You will get the amf response in the result or fault event functions

You have to do the folloing in PHP class to return the amf response.

1. Include the Zend_Amf library
Ex:
require_once 'Zend/Amf/Server.php';
2. Create object of amf server
$server = new Zend_Amf_Server();
3. Set the class that we need to map with
$server->setClass("className");
4. Map ActionScript value objects to the PHP value objects.
$server->setClassMap("className", "className");
5. Then print the handle response.
Ex:echo ($server->handle());

Create associative array in Flex

It's not possible to create array like array('branchId'=>1,'order'=>2)
For that first we have to define a variable as array
Ex:
var attr:Array = new Array();
attr["branchId"] = 1;
attr["order"] = 2;