无法理解 Flex 中的异常?
我正在尝试 learn.adobe.com 网站中提供的 flickr 代码,但出现此异常:
[RPC Fault faultString="Error #1090: XML parser failure: element is malformed." faultCode="Client.CouldNotDecode" faultDetail="null"] at mx.rpc.http::HTTPService/http://www.adobe.com/2006/flex/mx/internal::processResult()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:851] at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:188] at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43] at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74] at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()
我无法理解此异常。谁能帮我解决这个问题吗?
这是我输入的代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundGradientColors="[0xFFFFFF,0xAAAAAA]" horizontalAlign="left"
horizontalGap="15" verticalGap="15" width="459" height="371">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
public var photoBindable:ArrayCollection;
private function requestPhotos():void{
photoService.cancel();
var params:Object=new Object();
params.format = 'rss_200_enc';
params.tags = searchTerm.text;
photoService.send(params);
}
private function photoHandler(event:ResultEvent):void{
photoBindable=event.result.rss.channel.items as ArrayCollection;
}
]]>
</mx:Script>
<mx:HTTPService id="photoService"
url="http://api.flickr.com/services/feeds/photos_public.gne"
result="photoHandler(event)" />
<mx:HBox>
<mx:Label text="Flicker tags" />
<mx:TextInput id="searchTerm" />
<mx:Button label="Search" click="requestPhotos()"/>
</mx:HBox>
<mx:TileList width="100%" height="100%"
dataProvider="{photoBindable}"
itemRenderer="thumbnail">
</mx:TileList>
</mx:Application>
这是 itemRenderthumbnail.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="75" height="75"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
paddingBottom="5" paddingLeft="5" paddingTop="5">
<mx:Image width="75" height="75" source="{data.thumbnail.url}" />
<mx:Text text="{data.credits}" />
</mx:VBox>
I was trying the flickr code provided in the learn.adobe.com website, and I am getting this exception:
[RPC Fault faultString="Error #1090: XML parser failure: element is malformed." faultCode="Client.CouldNotDecode" faultDetail="null"] at mx.rpc.http::HTTPService/http://www.adobe.com/2006/flex/mx/internal::processResult()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\HTTPService.as:851] at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:188] at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43] at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74] at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete()
I can't understand this exception. Can anyone help me with this?
This is the code which i have typed
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundGradientColors="[0xFFFFFF,0xAAAAAA]" horizontalAlign="left"
horizontalGap="15" verticalGap="15" width="459" height="371">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
public var photoBindable:ArrayCollection;
private function requestPhotos():void{
photoService.cancel();
var params:Object=new Object();
params.format = 'rss_200_enc';
params.tags = searchTerm.text;
photoService.send(params);
}
private function photoHandler(event:ResultEvent):void{
photoBindable=event.result.rss.channel.items as ArrayCollection;
}
]]>
</mx:Script>
<mx:HTTPService id="photoService"
url="http://api.flickr.com/services/feeds/photos_public.gne"
result="photoHandler(event)" />
<mx:HBox>
<mx:Label text="Flicker tags" />
<mx:TextInput id="searchTerm" />
<mx:Button label="Search" click="requestPhotos()"/>
</mx:HBox>
<mx:TileList width="100%" height="100%"
dataProvider="{photoBindable}"
itemRenderer="thumbnail">
</mx:TileList>
</mx:Application>
This is itemRender thumbnail.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="75" height="75"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
paddingBottom="5" paddingLeft="5" paddingTop="5">
<mx:Image width="75" height="75" source="{data.thumbnail.url}" />
<mx:Text text="{data.credits}" />
</mx:VBox>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当然,XML 或 .php 文件中存在错误,可能是空格或其他内容;检查 xml 的第一行,该行必须仅以以下语句开头:
我很确定您忘记导入 itemRender:
无论如何,看看这个 page 即使是意大利语,代码也很容易理解。
希望有用
Of course there's an error in the XML or in the .php file, maybe blank space or something else; check the first line of xml which has to start only with the following statement:
I'm quite sure you forget to import the itemRender:
Anyway take a look to this page even if it's italian language the code is very simple to understand.
Hope to be useful
我认为问题出在这个标签event.result.rss.channel.items中,它不是items,而是item
去掉多余的's'......
这个例子很好...它对我有用...您可以使用下面的代码来检查
在此处打印我的代码...我向其中添加了更多内容
FlickrPrj.mxml
panelcomp.mxml
注意将FlickPrj.mxml 和panelcomp.mxml 放在同一目录中。
I think the problem is in this tag event.result.rss.channel.items it is not items it is item
Remove the extra 's' .....
The example is good...it worked for me...you can use this code below to check
Printing my code here...i added some more stuff to it
FlickrPrj.mxml
panelcomp.mxml
Note put FlickPrj.mxml and panelcomp.mxml in the same directory.
这意味着加载的xml文件没有正确写入,尝试在IE(或某些xml工具,例如altova)中打开它,看看有什么问题。
It means that the xml file that was loaded was not written properly , try to open it in IE ( or some xml tool such as altova ) and see whats wrong with it.