MACROMEDIA COLDFUSION MX 7.0.2-USING COLDFUSION MX WITH FLEX 2 Guide de l'utilisateur Page 112

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 256
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 111
112 Retrieve and Display Data
Insert a HTTPService component
For the blog reader in this lesson, you retrieve posts from Matt Chotins blog at http://
www.adobe.com/go/mchotinblog on a news aggregator website. Matt is a product manager
on the Flex team and writes about Flex in his blog.
You can use the HTTPService component to access the blog’s XML feed and retrieve
information about recent posts. The component lets you send an HTTP GET or POST
request, and then retrieve the data returned in the response.
1. In Source mode, enter the following <mx:HTTPService> tag immediately after the opening
<mx:Application> tag:
<mx:HTTPService
id="feedRequest"
url="http://weblogs.macromedia.com/mchotin/index.xml"
useProxy="false"/>
The url property specifies the location of the requested file, in this case the RSS 2.0 feed
of Matt Chotins blog. As of this writing, the URL was still valid, but you should check to
make sure it hasnt changed. You should use the latest RSS 2.0 URL listed on the right side
of the blog at http://www.adobe.com/go/mchotinblog.
The
useProxy property specifies that you dont want to use a proxy on a server. The
domain where Matt’s blog is located has a crossdomain.xml setup, so Flash Player can
access the remote data sources on this server, including RSS feeds. For more information,
see “Review your access to remote data sources” on page 108.
The next step is to prompt the application to send a request to the specified URL. You
decide to send the request automatically whenever the application starts, as follows.
2. In the <mx:Application> tag, add the following creationComplete property (in bold):
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="feedRequest.send()">
When your application is finished starting up, the HTTPService component’s send()
method is called. The method makes an HTTP GET or POST request to the specified
URL, and an HTTP response is returned. In this case, the RSS feed returns XML data.
Next, you want to check if the application is retrieving the RSS feed successfully. You can
do this by binding data to the Label control, as follows.
NOTE
If you want, you can also use the following alias in the component: http://
www.adobe.com/go/flex_blogfeed.
Vue de la page 111
1 2 ... 107 108 109 110 111 112 113 114 115 116 117 ... 255 256

Commentaires sur ces manuels

Pas de commentaire