First we have to download the library and can find it at http://code.google.com/p/as3corelib/. Then follow these steps to add your JSON library to your Flex project:
1. Download the .zip archive and extract it. What you need is the .swc file in the lib folder. 2. In Flex Builder / Flash Builder, go to your project’s properties, and then to the Flex Build Path panel. 3. Click on Add SWC, and select the as3corelib.swc file 4. In your project, add the following line: import com.adobe.serialization.json.JSON;
I managed to find a solution to the problem. It has to do with outdated app xml config files. So after importing project from source control, create a new application (eg. TestApp) and run / debug it, which works fine.
Compare the 2 app xml config files. In the new file at the top you will see a line:
application xmlns="http://ns.adobe.com/air/application/1.5"
In the old file I had: application xmlns="http://ns.adobe.com/air/application/1"
So you can change the old with the new app configuration.
It's because of your SDK version and has some incompatibility with main-app.xml in the application root folder.
It happens when you import some application so better to create test application with existing SDK version. Then replace the application main-app.xml with the automatically created one.
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());
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;
var resultArr:ArrayCollection = new ArrayCollection(e.result as Array);
var careeListData:ArrayCollection = new ArrayCollection();
var resultArray:Array = new Array();
if((resultArr.length > 0) && (resultArr[0]["whoForId"] != null)){