When referenceing in AS, use "result", when binding, use "lastResult":
dataProvider="{service.lastResult.rsp.photos.photo}"
But I strongly advise using a result handler instead of directly
binding. It is much easier to debug with a handler. I also advise
using resultFormat="e4x" Default is mx:Object.
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;
Invoke send:
var oRequest:Object = new Object();
oRequest.Arg1 = "value1";
var token:AsyncToken = service.send(oRequest);
token.myProperty1 = "myString or whatever";
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 bmelendy
Sent: Friday, May 25, 2007 6:16 PM
To: [email protected]
Subject: [flexcoders] Help with my first Flex App...
This has got to be a simple one. I am writing the tiny app given in
a video tutorial by Sho Kuwamoto. The tutorial is on displaying
flickr pictures in a basic tilelist control and is located here:
http://labs.adobe.com/technologies/flexbuilder2/tutorials/sho_kuwamoto
<http://labs.adobe.com/technologies/flexbuilder2/tutorials/sho_kuwamoto>
/
I have identified these KEY points:
1. An HTTPService call, of which mine looks like this:
<mx:HTTPService id="service"
url="http://api.flickr.com/services/rest/?
<http://api.flickr.com/services/rest/?>
method=flickr.photos.search&api_key=f09abdbe2fada94609244a5de3f4b8
de&per_page=9&tags={input.text}"/>
2. I call the web request with a button click like so:
<mx:Button x="262" y="18" label="Find" id="button1"
click="currentState='Results'; service.send()"/>
3. Finally, the data provider for the TileList control in the
tutorial is:
dataProvider="{service.result.rsp.photos.photo}"
However, while watching the video, as he types "services." he gets
two options, "result" and "resultFormat", however, I am only getting
an option for "resultFormat"? This is leading me to believe that
maybe the ".result" property has been removed??? And that is why my
application fails?
The end result is that I have this thing setup identical to the
tutorial but it just won't do anything on the results display. The
only thing that is different is that I went to Flickr and created my
own account and search feed at
http://www.flickr.com/services/api/explore/.
<http://www.flickr.com/services/api/explore/> (This is exactly the
method used to create a feed in the tutorial)
I have uploaded the project bin folder here:
http://brad.melendy.com/code/flex/flickr/Flickr.html
<http://brad.melendy.com/code/flex/flickr/Flickr.html>
I'd love to see this work and it looks so easy in the video (15
minutes!) but I've spent several hours on this now to no avail.
Thanks for any help out there