I'm using Flex 3.6 and ZEND AMF version 1.11
I have an array that shows in my trace using trace(ObjectUtil.toString(event.result));
It outputs as follows:
---This is a Test!---
//The Object Contains...
(Object)#0
code = "112"
path = "whateverthispathis"
Path is:
-----End of Test-----
In REST we used event.result.data.path
to get the path variable.
How do I get the path variable via Zend AMF without using XML and out of the PHP array I made posted below?
This is the PHP code I'm using to send it back to Flex:
$Data = Array();
$data = new params();
$data->path = $path;
$data->code = "10";
array_push($Data,$data);
return $data;
I have no problem throwing the results in lists, arrays, datagrids, etc., but there are times I just need to access 2 strings out of sometimes 20 strings only and this is why I'm asking.
Ok i have finally figured out my answer
The way we use Rest Services to access XML output like
<data>
<path>mypath</path>
</data>
That is accessed by using event.result.data.path; if using event:ResultEvent
Now with Zend AMF using examples based off Creating a Simple Crud Application and Shrinking and modifying the code to my liking yet the return of the php object remains the same...
I have to use this
var obj:Object = event.result;
trace("---This is a Test!---");
trace("Path is: "+String(obj[0].path));
trace("-----End of Test-----");
}
and it outputs as follows in my flash debugger console
---This is a Test!---
Path is: mypath
-----End of Test-----
Now obj[0]
is basically the first Object Row
"path" is the String in the Object set by using this sample code on the ZEND AMF PHP Class file
$Data = array();
$data = new login();
$data->path = mypath;
$data->passed = 10;
array_push($Data,$data);
return $Data;
If i wanted to access the passed
value i'd have to use
trace("Path is: "+String(obj[0].passed));
which would output as 10
If i wanted to Access the 2nd set of Object Values and so on...
increment the obj[0]
to obj[1]
and increase for any additional Rows
In my case any obj[1]
would output as null
Since I have no additional rows at this time.
Of Course mostly we hardly ever need to access multiple rows of Objects since thats commonly added as ArrayCollections or Arrays and Displayed in Datagrids and Lists and whatnot. Like the Simple Crud Demonstration at the link below shows.
Also i use Open Flex 3.6 SDK therefore in the Simple Crud Application i had to modify all the s:
(Spark Containers) To mx: and eliminate fx:
Declarations as well thats just a note for those attempting to use the Simple Crud PHP Zend Application and not using Flex 4 nor Flex 4.5
The Simple Crud i was referring to is linked as follows
http://www.adobe.com/devnet/flex/articles/crud_flex_php_zend.html