I have the following question. How can I select a php file as source in my fx model connection.
I want to use in my fx model source a php file that returns an xml file. Is this possible?
Now I have tried to work with an http service to read the php file on running and with an xmllistcollection. This is my code:
<?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.*">
<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>
I don't get any errors but I don't see any information in my list.