问题描述
我使用的是 Flex 3.6 和 ZEND AMF 1.11 版
I'm using Flex 3.6 and ZEND AMF version 1.11
我有一个数组,使用 trace(ObjectUtil.toString(event.result));
输出如下:
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-----
在 REST 中,我们使用 event.result.data.path
来获取路径变量.
In REST we used event.result.data.path
to get the path variable.
如何在不使用 XML 的情况下通过 Zend AMF 获取路径变量,并且不使用我在下面发布的 PHP 数组?
这是我用来将其发送回 Flex 的 PHP 代码:
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;
我可以将结果放入列表、数组、数据网格等中,但有时我只需要访问 20 个字符串中的 2 个字符串,这就是我要问的原因.
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
我们使用 Rest Services 访问 XML 输出的方式,如
The way we use Rest Services to access XML output like
<data>
<path>mypath</path>
</data>
通过 event.result.data.path 访问;如果使用 event:ResultEvent
That is accessed by using event.result.data.path; if using event:ResultEvent
现在使用 Zend AMF 使用基于创建简单 Crud 应用程序和收缩并根据我的喜好修改代码的示例,但 php 对象的返回保持不变...
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...
我必须使用这个
var obj:Object = event.result;
trace("---This is a Test!---");
trace("Path is: "+String(obj[0].path));
trace("-----End of Test-----");
}
它在我的 Flash 调试器控制台中输出如下
and it outputs as follows in my flash debugger console
---这是一个测试!---路径是:mypath-----测试结束-----
---This is a Test!---Path is: mypath-----End of Test-----
现在 obj[0]
基本上是第一个 Object Row路径"是在 ZEND AMF PHP 类文件中使用此示例代码设置的对象中的字符串
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;
如果我想访问 passed
值,我必须使用trace("Path is: "+String(obj[0].passed));
将输出为 10
If i wanted to access the passed
value i'd have to usetrace("Path is: "+String(obj[0].passed));
which would output as 10
如果我想访问第二组对象值等等...将 obj[0]
增加到 obj[1]
并增加任何额外的行在我的情况下,任何 obj[1]
将输出为 null
因为我此时没有其他行.
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 RowsIn my case any obj[1]
would output as null
Since I have no additional rows at this time.
当然,大多数情况下我们几乎不需要访问多行对象,因为它们通常作为 ArrayCollections 或数组添加并显示在数据网格和列表中等等.就像下面链接中的 Simple Crud 演示一样.
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.
我还使用 Open Flex 3.6 SDK,因此在 Simple Crud 应用程序中,我必须将所有 s:
(Spark Containers)修改为 mx: 并消除 fx:
声明对于那些尝试使用 Simple Crud PHP Zend 应用程序而不使用 Flex 4 或 Flex 4.5 的人来说,这只是一个说明
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
我所指的 Simple Crud 链接如下http://www.adobe.com/devnet/flex/articles/crud_flex_php_zend.html
The Simple Crud i was referring to is linked as followshttp://www.adobe.com/devnet/flex/articles/crud_flex_php_zend.html
这篇关于从 Zend AMF 对象访问字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!