O'Reilly logo

Beginning Adobe® AIR™: Building Applications for the Adobe Integrated Runtime by Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required