B.2. Chapter 7 Exercise

By utilizing the classes created by the Import Web Services (WSDL) wizard, I was able to replicate the functionality demonstrated by Listing Listing 7-13. Take a look at Listing B-2, and you will see that within the init() function, an instance of the StockQuote class is created and an event listener is added to handle the results of this service. There is also a getQuote() function, which when called simply passes the stock ticker symbol into the getQuote() function of the StockQuote class. Finally, the result handler function simply displays the results within an Alert window. The XML result can be seen in Figure B-2.

Example B-2. The solution for the Chapter 7 Exercise
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
    creationComplete="init()">
    <!--
    Use the project created in the Import Web Service section of this
    chapter to duplicate the functionality that was demonstrated
    in Listing 7-13 and Figure 7-10 of this chapter. Instead of
    calling the WSDL directly as demonstrated in Listing 7-13,
    utilize the ActionScript classes created by the WSDL import wizard.
    -->
    <mx:Script>
        <![CDATA[
        import net.webservicex.GetQuoteResultEvent;
        import net.webservicex.StockQuote;
        private var quote:StockQuote;

        private function init():void{
            quote = new StockQuote();
            quote.addgetQuoteEventListener(quoteResult);
}

        private function getQuote():void{
            quote.getQuote(symbol.text)
        }

        private function quoteResult(event:GetQuoteResultEvent): ...

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.