7.4. MashUps

A MashUp is defined as an application that utilizes data from more than one source and combines them into a single user experience. The following example will utilize two data services to supply different types of data about the same stock symbol. First, it will use the same web service as was used in Listing 7-13 to get pricing information on the stock symbol. And then it will also use a RESTful service to get news information from Yahoo about the stock symbol.

The components being used are <mx:WebService> to connect to the stock data service and <mx:HTTPService> to connect to the Yahoo news service.

To create this MashUp application, start by creating a new AIR application named Chapter7_MashUp. Copy the code from Listing 7-14 into the Chapter7_MashUp.mxml file. A further step using an item renderer is shown in Listing 7-15.

Example 7-14. The complete code for Chapter7_MashUp.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    width="500" height="500">

    <mx:Script>
        <![CDATA[
          import mx.rpc.events.ResultEvent;
          import mx.controls.Alert;
          [Bindable]
          private var stockInfo:XML;

          private function getStockData():void{
            stockInfo = null;
            news.dataProvider = null;
            webService.GetQuote(symbol.text);
            httpService.send();
          }

          private function webServiceOnLoad(event:ResultEvent):void{
            stockInfo = new XML(event.result);
          }
          private function httpServiceOnLoad(event:ResultEvent):void{ news.dataProvider = event.result.rss.channel.item; ...

Get Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.