Absorbing the Amazon Web Service


Amazon is one of the most well-known Internet storefronts on the planet, and they have opened up their product database to the public for free.

With the Amazon web service, you can search their database web for books, DVDs, and more, and have the results sent back to an application you design and build.

The first thing you will have to do is get your key from Amazon by signing up at

http://www.amazon.com/gp/browse.html/103-7710202-8564650?%5Fencoding=UTF8&node=3435361

The key lets Amazon know who is using the search engine.

When you have gotten your personal key, you will need to download the sample file for this application from the accompanying website. The application itself has everything but the key.

The purpose of this application is to see the power of web services. This example allows you to search Amazon's DVD collection at will, and it returns 10 results each time. When one of those results is selected, it displays an image of that DVD. When you have downloaded the sample application from the website and have gotten your key from amazon.com, open the file amazonFinal.fla and follow these steps to make it work:

1.

Select the WebServiceConnector component in the top left of the stage.

2.

Open the Component Inspector panel (Window, Component Inspector).

3.

Select the Binding tab, where you will see a list of all the bindings that have already been set.

4.

Choose the last binding, the params.keyWordSearchRequest.devtag binding.

5.

Select the Bound To field and click the magnifying glass that appears.

6.

When the Bound To dialog box appears, select the bottom check box, Use a Constant Value.

7.

Then in the accompanying field, type in your key.

8.

Click OK, and test the application, which should look like Figure 25.12.

Figure 25.12. The Amazon DVD application using web services.


Let's go over the code in the first frame of the Actions layer.

The first section creates the object to listen to the search button. We then assign the event to it that, when triggered, activates the webServiceConnector component. Finally, we add the event listener to the Search button.

 //the listener object var amzObj:Object = new Object(); //the event amzObj.click=function(){     myConnector.trigger(); } //add the event listener to the button search_butn.addEventListener("click",amzObj); 

This application is not using all the results that are returned. Use the Web Services panel to see what else is available (http://soap.amazon.com/schemas2/AmazonwebServices.wsdl). You can also see all the different web methods we did not use, such as author search. The possibilities are endless, and this application is merely a good start.




Macromedia Flash Professional 8 Unleashed
Macromedia Flash Professional 8 Unleashed
ISBN: 0672327619
EAN: 2147483647
Year: 2005
Pages: 319

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net