Here is a bit of sample code, general, not using your app, but it might
help.
In your case the row that reads:
var xlMyListData:XMLList = xmlResult.myListData;
might be
var xlMyListData:XMLList = xmlResult.stafflist.staffid;
Tracy
Sample code using HTTPService, e4x, handler function to populate a list
item
The DataGrid tag:
<mx:DataGrid id="dg" dataProvider="{_xlcMyListData}" .../>
The HTTPService tag:
<mx:HTTPService id="service" resultFormat="e4x" result="onResult(event)"
fault="..../>
Script block declaration:
import mx.rpc.Events.ResultEvent;
[Bindable]private var _xlcMyListData:XMLListCollection;
Result Handler function:
private function onResult(oEvent:ResultEvent):void {
var xmlResult:XML = XML(event.result); //converts
result Object to XML. can also use "as" operator
var xlMyListData:XMLList = xmlResult.myListData; //depends on xml
format, is row data
_xlcMyListData = new XMLListCollection(xlMyListData); //wrap the
XMLList in a collection
trace(_xlcMyListData.toXMLString()); //so you can see
exactly how to specify dataField or build labelFunction
}//onResult
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of tweakfreak33
Sent: Tuesday, April 17, 2007 7:13 PM
To: [email protected]
Subject: [flexcoders] Re: Binding ArrayCollection to HTTPService
method="POST"
Hi Tracy,
That's just it... I cant figure out how to "just assign the result to
the ArrayCollection (or XMLListCollection) in the result handler" :-(
What could the code look like in my first <Snip> below?
TIA
Danny
PS: you could so solve this in 15mins, I guess it would be rude to ask
for 'remote desktoping' or even a voice call over the web/fone..!
Do you do any kind of (paid) remote support, even for a poor secondary
school network admin :-|
--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Don't bother with binding in this case, just assign the result to the
> ArrayCollection (or XMLListCollection) in the result handler.
>
> Tracy
>
>
>
> ________________________________
>
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of tweakfreak33
> Sent: Monday, April 16, 2007 5:03 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com>
> Subject: [flexcoders] Binding ArrayCollection to HTTPService
> method="POST"
>
>
>
> Hi All,
>
> Firstly apologies for posting all this code!
> I have the following app that works fine, it's displays data from a
> mysql db in a datagrid, and also allows a user to insert a new record
> in the db...
>
> #########################<START SNIP>##########################
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml>
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
xmlns="*"
> layout="absolute" backgroundGradientColors="[#0080ff,#80ffff]"
> creationComplete="send_data()">
>
> <!-- This is the Script to SetUp Functions-->
> <mx:Script>
> <![CDATA[
> private function youveClicked():void {
> mx.controls.Alert.show('You Clicked!!!');
> }
> private function send_data():void {
> staffcodeRequest.send();
> }
> ]]>
> </mx:Script>
>
> <!-- This is the HTTPService-->
> <mx:HTTPService id="staffcodeRequest"
> url="http://192.168.0.84/amfphp/services/staffcode.php
<http://192.168.0.84/amfphp/services/staffcode.php>
> <http://192.168.0.84/amfphp/services/staffcode.php
<http://192.168.0.84/amfphp/services/staffcode.php> > "
> useProxy="false" method="POST">
> <mx:request xmlns="">
>
>
<firstname>{firstname.text}</firstname><surname>{surname.text}</surname>
>
<staffcode>{staffcode.text}</staffcode><emailaddress>{emailaddress.text}
> </emailaddress><department>{department.text}</department>
> </mx:request>
> </mx:HTTPService>
>
> ###########################<END SNIP>##########################
>
> I'm thinking of Binding the the xml formated results into an
> arrayCollection & then use the filterFunction to allow a user to
> filter the data (is this possible?).
> (Below is some code that I found in a thread & am using to work from
> as an example)
>
> #########################<START SNIP>##########################
>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml>
> <http://www.adobe.com/2006/mxml <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:"Dartford"},
> {name:"school B", city:"Pomona "},
> {name:"School C", city:"Phillipsburg"}
> ])
> }
>
> 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>
>
> ###########################<END SNIP>##########################
>
> If it is possible, I need some help in integrating the following code,
> (I've tried but keep getting {1151: A conflict exists with definition
> staffcodeRequest in namespace internal.})
>
> #########################<START SNIP>##########################
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml>
> <http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> > "
xmlns="*"
> layout="absolute" backgroundGradientColors="[#0080ff,#80ffff]"
> creationComplete="send_data()">
>
> <!-- This is the Script to SetUp Functions-->
> <mx:Script>
> <![CDATA[
>
> private function youveClicked():void {
> mx.controls.Alert.show('You Clicked!!!');
> }
> private function send_data():void {
> staffcodeRequest.send();
> }
>
> <!--Can I just Bind the arrayCollection here-->
>
> import mx.collections.ArrayCollection;
> [Bindable]
> private var staffcodeRequest:ArrayCollection;
>
> <!--This part I also need to change as my data is returned on the fly
> from a mysql lookup rather than a static xml file-->
>
> private function filterDemo():void{
> staffcodeRequest.filterFunction = searchDemo;
> staffcodeRequest.refresh();
> }
> private function searchDemo(item:Object):Boolean{
> var isMatch:Boolean = false
> if(item.staffcode.toLowerCase().search(search.text.toLowerCase())
> != -1){
> isMatch = true}
> return isMatch;
> }
> private function clearSearch():void{
> staffcodeRequest.filterFunction = null;
> staffcodeRequest.refresh();
> search.text = '';
> }
> ]]>
> </mx:Script>
>
> <!-- This is the HTTPService-->
> <mx:HTTPService id="staffcodeRequest"
> url="http://192.168.0.84/amfphp/services/staffcode.php
<http://192.168.0.84/amfphp/services/staffcode.php>
> <http://192.168.0.84/amfphp/services/staffcode.php
<http://192.168.0.84/amfphp/services/staffcode.php> > "
> useProxy="false" method="POST">
> <mx:request xmlns="">
>
>
<firstname>{firstname.text}</firstname><surname>{surname.text}</surname>
>
<staffcode>{staffcode.text}</staffcode><emailaddress>{emailaddress.text}
> </emailaddress><department>{department.text}</department>
> </mx:request>
> </mx:HTTPService>
>
> ###########################<END SNIP>##########################
>
> What I am strugling with is BINDING the returned xml formated results
> to an arrayCollection, so that I can assign a filterFunction.
>
> Help would be grate ;-)
>
> TIA
> Danny
>