Hi All,

The following app displays and filters the data correctly, but I want
to change the hardcoded XML data source to a HTTPservice source.
I have a url that generates dynamic XML data, I just dont know how to
change the hardcoded source to point to the dynamic source... Can
anyone Help!

################### Static Data Source ##################
<?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>
################## /Static Data Source ##################





I dont know how to change the following static data source:

################ SNIP Static Data Source ################
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"},
           ])
           }
############### /SNIP Static Data Source ################

and modify it so that it gets data from the following dynamic source:

################## Dynamic Data Source ##################
<mx:HTTPService id="getStaffList"
url="http://192.168.0.84/amfphp/stafflist.php"; />
################# /Dynamic Data Source ##################



NB:
The above HTTPservice stafflist.php script generates the following
data format:
################ SNIP Generated XML Data ################
<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>
############### /SNIP Generated XML Data ################

Reply via email to