はい、このような質問がありますが、活動も回答もありません。
HTTPService を使用して外部 XML ファイルからデータをロードしたいのですが、同じ HTTPService の ResultEvent で、XML のデータを ArrayCollection に入力してもらいたいと考えています。
この XML には ArrayCollection が理想的だと思います。しかし、私は提案を受け入れています。
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 にバインドされた List を配置して、実際にデータが取り込まれているかどうかを実際に確認したからです。
<mx:List dataProvider="{PhotoData}" labelField="name"/>
また、リストにはデータが表示されなかったため、想定どおりに機能していません。
助けてくれてありがとう。
編集
ノート
<mx:List/>
used は、ArrayCollection が実際に設定されていることを確認するためのものであり、アプリでは使用されません。
Bozhoのアドバイスを受けた結果。
Bozho の変更により、Flex は var タイプ エラーを報告しなくなりましたが、一度実行すると。Adobe Flash はこれを報告します。
TypeError: エラー #1034: 型強制に失敗しました: mx.utils::ObjectProxy@22cd311 を mx.collections.ArrayCollection に変換できません。PhotoGallery/getDataResultHandler()[C:\Users\Fábio Antunes\Documents\Flex Builder 3\Photo Gallery\src\ActionScripts\PhotoGallery.as:56] で PhotoGallery/__getData_result()[C:\Users\Fábio Antunes\Documents \Flex Builder 3\Photo 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] で 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: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() で
さて、Flashがエラーを報告する23行目:
PhotoData = ArrayCollection(event.result);
23 行目は次のとおりです。
result="getDataResultHandler(event)"