MACROMEDIA FLEX-GETTING STARTED WITH FLEX User Manual Page 43

  • Download
  • Add to my manuals
  • Print
  • Page
    / 148
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 42
5. In the function, cancel any previous requests to photo
Service by using the cancel method. The instance name
of the HTTPService component is photoService.
6. Create an Object variable named params.
7. Create a format parameter of the params variable with a
value of rss_200_enc. This value tells Flickr how to pack-
age the response.
8. Create a tags parameter of the params variable with a
value of searchTerms.text. This is the value that was en-
tered in the search field.
9. Send the request and params variable to Flickr by using
the send method of photoService. Example 3-8 shows
the complete function.
Example 3-8. The complete requestPhotos function
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var photoFeed:ArrayCollection;
private function requestPhotos():void{
photoService.cancel();
var params:Object = new Object();
params.format = 'rss_200_enc';
params.tags = searchTerms.text;
photoService.send(params);
}
]]>
</mx:Script>
Now it’s time to create the HTTPService result handler and to
populate the photoFeed XML variable:
1. After the requestPhotos() function, create a private
function named photoHandler and pass an event of type
ResultEvent to the function. The return type is void. The
photoHandler handles the response from the HTTPSer
A Flickr Viewer | 27
Page view 42
1 2 ... 38 39 40 41 42 43 44 45 46 47 48 ... 147 148

Comments to this Manuals

No comments