我的项目有问题,我尝试用从 php 文件中获取的 xml 数据填充列表。我用 httpservice 调用 php 文件,这个文件返回 xml 数据。现在似乎有问题,但我没有收到任何错误。我只是在调试后才知道我的 XMLListCollection 仍然为空。
这是我的代码:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:components="components.*"
creationComplete="httpService.send()">
<s:layout>
<s:VerticalLayout paddingTop="20" gap="20"
horizontalAlign="center" />
</s:layout>
<fx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
private var alert:Alert;
private function httpService_fault(evt:FaultEvent):void {
var title:String = evt.type + " (" + evt.fault.faultCode + ")";
var text:String = evt.fault.faultString;
alert = Alert.show(text, title);
Bezoekers.removeAll();
}
private function httpService_result(evt:ResultEvent):void {
var xmlList:XMLList = XML(evt.result).bezoekers.bezoeker;
Bezoekers = new XMLListCollection(xmlList);
}
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="httpService"
url="http://localhost/projectnieuw/src/data/bezoekersList.php"
resultFormat="e4x"
fault="httpService_fault(event);"
result="httpService_result(event)" />
<!--<fx:Model id="lijstAlleLeden" source="httpAlleLeden" />-->
<!--<s:ArrayCollection id="acBezoekers" source="{Bezoekers}"/>-->
<s:XMLListCollection id="Bezoekers"/>
</fx:Declarations>
<components:Heading/>
<s:HGroup gap="50">
<components:BezoekersList bezoekerList="{Bezoekers}" />
<components:ReservationForm/>
</s:HGroup>
</s:Application>
我似乎不明白出了什么问题。
提前致谢
来自比利时的问候