是的,有这样一个问题,但没有活动,也没有答案。
我希望使用httpservice从外部XML文件加载数据,并且在同一httpservice的resultEvent上,我希望他用XML中的数据填充arraycollection。
我认为ArrayCollection是这个XML的理想选择。但我愿意接受建议。
XML
<?xml version="1.0" encoding="utf-8"?>
<PhotoGalleryData>
<Photo>
<id>1</id>
<name>Summer Vacation</name>
<description>In vacation</description>
<source>vacation.JPG</source>
</Photo>
<Photo>
<id>2</id>
<name>Winter Vacation</name>
<description>coold</description>
<source>vacation2.JPG</source>
</Photo>
</PhotoGalleryData>
我以为这条简单的线
getDataResultHandler()
,将足以填充ArrayCollection。
<mx:HTTPService id="getData"
url="{XMLDataFileLocation}"
fault="getDataFaultHandler()"
result="getDataResultHandler()"/>
[Bindable]
private var PhotoData:ArrayCollection;
private function getDataResultHandler():void
{
PhotoData = new ArrayCollection(getData.lastResult.PhotoGalleryData.photo)
}
但我想不是,因为我只是确定我已经放置了一个绑定到arraycollection的列表,以查看它是否真的被填充了。
<mx:List dataProvider="{PhotoData}" labelField="name"/>
列表中没有显示任何数据,因此无法正常工作。
谢谢你的帮助。
编辑
注释
这个
<mx:List/>
过去只是为了
确定arraycollection是
实际上,它不会用于
应用程序。
接受博日建议的结果。
使用bozho changes,flex不再报告var类型错误,但在我运行它之后。Adobe Flash确实报告了这一点。
类型错误:错误1034:类型强制
失败:无法转换
mx.utils::objectProxy@22CD311收件人
mx.collections.arraycollection。在
photogallery/getdataresulthandler()[c:\users\f_bio
安图内斯\文档\ flex builder 3 \照片
库\SRC\ActionScripts\PhotoGallery.as:56]
在
照片库/uu getdata_result()[c:\users\f_bio
安图内斯\文档\ flex builder 3 \照片
Gallery\src\photogallery.mxml:23]在
flash.events::EventDispatcher/DispatcheventFunction()。
在
flash.events::EventDispatcher/Dispatchevent()。
在
mx.rpc.http.mxml::httpService/
http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C
:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\mxml\httpservice.as:290]
在
rpc::abstractInvoker(抽象调用程序)/
http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C
:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\abstractinvoker.as:193]
在
mx.rpc::responder/result()[c:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\responder.as:43]
在
mx.rpc::asyncRequest/acknowledge()[c:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\asyncRequest.as:74]
在
directhttpmessageresponder/completehandler()[c:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\directhttpchannel.as:403]
在
flash.events::EventDispatcher/DispatcheventFunction()。
嗯,第23行的flash报告了错误,它是:
PhotoData = ArrayCollection(event.result);
第23行是:
result="getDataResultHandler(event)"