1

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.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
LeeWazHere
  • 26
  • 4
  • Your post is quite long but I'm not seeing any question anywhere. – laurent Dec 03 '11 at 14:09
  • my question is this Im too familiar with rest like using event.result.data.path to get the path string dunno how its done with zend amf objects thou ive tried too many diff ways looked up many references to no avail to how to do this simple thing – LeeWazHere Dec 03 '11 at 15:22
  • 1
    @Laurent: He wants to retrieve the "path" value from the object the PHP code is returning, using Zend AMF. It's probably just ordinary ActionScript, but I don't know Flex, so I can't answer the question. – Robert Harvey Dec 03 '11 at 17:20
  • 1
    It would be very helpful if you included proper capitalization in your questions in the future. Leaving everything lower case made your question very hard to read. – Robert Harvey Dec 03 '11 at 17:21
  • It's a bit hard to tell from your code examples, but if it is not event.result.data.path, I guess it could be event.result.data[1], if the data is an array. Or possibly event.result.path. – Lars Blåsjö Dec 03 '11 at 18:00
  • I think we're all just poking in the dark, but assuming he wants to debug the data he gets in Flash, he could use a logger such as the one mentioned there - http://stackoverflow.com/a/8053138/561309 Type `Log.dump(event.result)` to get what's inside `event.result` – laurent Dec 03 '11 at 18:07

1 Answers1

0

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

LeeWazHere
  • 26
  • 4