Hi All, Can anyone help? It is probably something very simple :-s The following code works ok, but I need to change the source of the XML data...
####################### CODE ##################### <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initData()"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] private var dataList:ArrayCollection ; private function initData():void{ dataList= new ArrayCollection([ {name:"school A", city:"Paris"}, {name:"school B", city:"Pomona "}, {name:"School C", city:"Phillipsburg"}, {name:"School D", city:"Liverpool"}, {name:"School E", city:"Madrid"}, ]) } private function filterDemo():void{ dataList.filterFunction = searchDemo; dataList.refresh(); } private function searchDemo(item:Object):Boolean{ var isMatch:Boolean = false if(item.name.toLowerCase().search(search.text.toLowerCase()) != -1){ isMatch = true } return isMatch; } private function clearSearch():void{ dataList.filterFunction = null; dataList.refresh(); search.text = ''; } ]]> </mx:Script> <mx:Form> <mx:FormItem label="Search Name" direction="horizontal"> <mx:TextInput id="search" change="filterDemo()" /> <mx:Button label="Clear Search" click="clearSearch()" /> </mx:FormItem> </mx:Form> <mx:DataGrid dataProvider="{dataList}" width="400" height="400"> <mx:columns> <mx:DataGridColumn headerText="Name" dataField="name" /> <mx:DataGridColumn headerText="City" dataField="city" /> </mx:columns> </mx:DataGrid> </mx:Application> ####################### /CODE ##################### As the XML data source in the above example is hardcoded, I want to modify the code to get the data from a URL, but am having trouble..! The following code is what I am having trouble with setting the XML source... Can anyone help, suggest how I might change #################### CHANGE THIS #################### private function initData():void{ dataList= new ArrayCollection([ {name:"school A", city:"Paris"}, {name:"school B", city:"Pomona "}, {name:"School C", city:"Phillipsburg"}, {name:"School D", city:"Liverpool"}, {name:"School E", city:"Madrid"}, ]) } #################### /CHANGE THIS #################### #################### TO THIS ##################### private function initData():void{ dataList= new ArrayCollection( <mx:HTTPService id="getStaffList" url="http://192.168.0.84/amfphp/stafflist.php" /> ) } #################### /TO THIS #################### This should be the final code that works, but doesnt :-( ####################### CODE ##################### <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="getStaffList.send();"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] private var dataList:ArrayCollection ; private function getStaffList():void{ dataList= new ArrayCollection; } private function filterDemo():void{ dataList.filterFunction = searchDemo; dataList.refresh(); } private function searchDemo(item:Object):Boolean{ var isMatch:Boolean = false if(item.name.toLowerCase().search(search.text.toLowerCase()) != -1){ isMatch = true } return isMatch; } private function clearSearch():void{ dataList.filterFunction = null; dataList.refresh(); search.text = ''; } ]]> </mx:Script> <mx:HTTPService id="getStaffList" url="http://192.168.0.84/amfphp/stafflist.php" /> <mx:Form> <mx:FormItem label="Search" direction="horizontal"> <mx:TextInput id="search" change="filterDemo()" /> <mx:Button label="Clear Search" click="clearSearch()" /> </mx:FormItem> </mx:Form> <mx:DataGrid dataProvider="{dataList}" width="400" height="400"> <mx:columns> <mx:DataGridColumn headerText="Staff Code" dataField="staffcode" /> <mx:DataGridColumn headerText="Department" dataField="department" /> </mx:columns> </mx:DataGrid> </mx:Application> ####################### /CODE ##################### The above code should be getting it's XML data provided by: <mx:HTTPService id="getStaffList" url="http://192.168.0.84/amfphp/stafflist.php" /> If I brouwse to the stafflist.php file from a browser I get XML in a valid format :-) How do I get the data into my flex app??? ####################### XML ##################### <stafflist> <staffmember> <staffid>30</staffid> <firstname>sarina</firstname> <surname>redmond</surname> <staffcode>sre</staffcode> <emailaddress>[EMAIL PROTECTED]</emailaddress> <department>science</department> </staffmember> <staffmember> <staffid>27</staffid> <firstname>jayson</firstname> <surname>poole</surname> <staffcode>jpo</staffcode> <emailaddress>[EMAIL PROTECTED]</emailaddress> <department>business studies</department> </staffmember> <staffmember> <staffid>32</staffid> <firstname>Karina</firstname> <surname>Bishop</surname> <staffcode>kbi</staffcode> <emailaddress>[EMAIL PROTECTED]</emailaddress> <department>reception</department> </staffmember> <staffmember> <staffid>33</staffid> <firstname>James</firstname> <surname>Stuart</surname> <staffcode>jst</staffcode> <emailaddress>[EMAIL PROTECTED]</emailaddress> <department>PE</department> </staffmember> </stafflist> ####################### /XML #####################

