B.10. Chapter 15 Exercise

This exercise asked you to create an application that uses an HTML component to load in a web page, then upon request create a new window that displays all the images that were part of the HTML content within the HTML component. Take a look at Listing B-17, and you will see that there is an HTML component with an ID of HTML that will display http://images.google.com. There is a second component of type Button that will call the showImages() function when clicked. The showImages() function is the heart of this application. It first searches for images within the HTML component by calling getElementsByTagName ("img") on html.htmlLoader.window.document.documentElement. These images are stored as an object. A new Window component is created, the images object is looped through, and a new Image component is created on each iteration; the image source is set to the source of the image from the images object. The new Image component is then added to the window as a child. The results can be seen in Figure B-13.

Example B-17. The solution file for the Chapter 15 Exercise
<?xml version="1.0" encoding="utf-8"?> <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="850" height="575"> <!-- Create an application that shows all of the images that a Web page contains in a separate window. Hint, you will need to parse out the images using getElementsByTagName(). Also, see Chapter 29 for information on the Windowing API. --> <mx:Script> ...

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.