HTTPService とそれが返すデータについて質問があります。
この XML を考えてみましょう。
<PhotoGalleryData>
<Photo>
<id>1</id>
<name>Summer Vacation</name>
<description>In vacation</description>
<fullImage>originalImg/1.JPG</fullImage>
</Photo>
<Photo>
<id>2</id>
<name>Winter Vacation</name>
<description>coold</description>
<fullImage>originalImg/2.JPG</fullImage>
</Photo>
</PhotoGalleryData>
ご覧のとおり、 Photoの 2 つのインスタンスがあり、それは HTTPService を使用して取得されます。同じ HTTPService の結果イベントで、返されたPhoto.lastResult
という名前のインスタンスの数を数えてもらいたいと思います。
これはばかげた質問ですが、Adobe Docs のどこにも見つかりません。
もちろん、どんな助け、ヒント、提案も大歓迎です。
メドワ
それでも0を返すので、盲目か何かでなければなりません。
ここに何か欠けていますか?
MXML
<mx:HTTPService id="getData"
url="{XMLDataFileLocation}"
showBusyCursor="true"
fault="getDataFaultHandler()"
result="getDataResultHandler(event)"/>
ActionScript
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
private var xmlData:XMLList;
private var numItems:int;
private function getDataResultHandler(evt:ResultEvent):void
{
if (evt.result.PhotoGalleryData)
{
xmlData = XML(evt.result).descendants("Photo");
numItems = xmlData.length();
Alert.show('Nº '+numItems,'num de Photo');
}
}