访问字符串与Zend的AMF对象 [英] Accessing Strings From Zend AMF Objects

查看:106
本文介绍了访问字符串与Zend的AMF对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Flex 3.6和Zend AMF版本1.11

I'm using Flex 3.6 and ZEND AMF version 1.11

我有一个数组在我的跟踪显示使用跟踪(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.

如何获得通过的Zend AMF的路径变量,而无需使用XML和出PHP数组我做了下面贴?

这是PHP code我用它发回的Flex:

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;

我有没有问题抛的结果列表,数组,数据网格,等等,但有次我只需要访问2串出来只是有时20串,这就是为什么我问。

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服务来访问XML输出​​像

The way we use Rest Services to access XML output like

<data>
<path>mypath</path>
</data>

这是通过使用event.result.data.path访问;如果使用事件:的ResultEvent

That is accessed by using event.result.data.path; if using event:ResultEvent

现在使用实例的Zend AMF基于断创建一个简单的CRUD应用程序,并缩小和修改code合我意尚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-----");
}

和它输出在我的闪存调试器控制台如下:

and it outputs as follows in my flash debugger console

---这是一个测试!--- 路径是:mypath中 -----测试结束-----

---This is a Test!--- Path is: mypath -----End of Test-----

现在 OBJ [0] 基本上是第一个对象行 路径是在对象使用该样本code上了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; 

如果我想访问通过值我不得不使用 跟踪(路径是:+字符串(OBJ [0] .passed)); 这将作为 10 输出

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

如果我想进入第2集对象值等等... 递增 OBJ [0] OBJ [1] ,并增加任何额外的行 在我的情况下,任何 OBJ [1] 将输出为因为我没有更多的行,在这个时候。

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.

当然了,我们大多是很少需要访问多个行的对象,因为通常添加作为ArrayCollections或阵列和数据网格和列表和诸如此类的东西显示,多数民众赞成。像简单的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.

此外,我使用开放式的Flex 3.6 SDK,因此在简单的CRUD应用程序,我不得不修改所有 S:(Spark容器)要MX:和消除 FX:声明,以及多数民众赞成对那些试图使用简单的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

在简单的CRUD我指的是被链接如下 http://www.adobe.com/devnet/flex/articles/crud_flex_php_zend.html

The Simple Crud i was referring to is linked as follows http://www.adobe.com/devnet/flex/articles/crud_flex_php_zend.html

这篇关于访问字符串与Zend的AMF对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆