| ThinkDigit Home |
|
||||||||||||
|
|||||||||||||
|
|||||||||||||
|
||||||||||||
|
Introduction
Last time we created an widget which allowed you to search on Twitter, which introduced you to Flex Catalyst, and showed how it could be used to create a rich UI for you application. In this tutorial we will create an application which loads an XML gallery exported from Picasa, and displays the files in a gallery.
Picasa 3 allows one to export their images as a HTML galleries, and also supports an option to export the image gallery as an XML. If you choose to export as XML, Picasa will create an XML file with information about the images you selected to export. The file created by Picasa is quite verbose, and has a lot of detail we wont use, however you can expand your own application to utilize the same.
Our application will read in this data, and manipulate it using E4X (ECMAScript for XML) which is a simple and powerful way of manipulating XML documents. ActionScript 3 treats XML as a native type like any integer or string. We will only use a very small subset of these features.
Exporting the XML from Picasa
The feature we are looking for here is “Export as HTML Page...” which is found in the “Folder” menu item in Picasa. You can select the images you want in your gallery, and use this feature to generate an HTML gallery of the selected images. We will however use this to output an XML index for our gallery instead and develop our own front-end.
This option will show a dialog which will allow you to select the options for you export. You can choose the resolution at which the images will be resized, or you can just choose to export them at their original resolution. We will select 800 pixels so that all images have a similar size. Choose where to save it, and in the list of templates, select “XML Code”.
This will take a few minutes depending on the number of images selected, and will launch the XML file in your default editor. Before using this in the application, let us take a look at the XML format of the file:
<?xml version="1.0" encoding="utf-8" ?> <album> <albumName>Recently Updated</albumName> <albumItemCount>24</albumItemCount> <albumCaption></albumCaption> <images> <image>...
We have a root tag of <album> with an <albumName>, a count of the images in the album <albumItemCount>, a caption for the album <albumCaption> and an <images> tag which contains information about each image in an <image> tag.
Here is what the image tag looks like:
<image> <isFirstImage>false</isFirstImage> <isPrevImage>true</isPrevImage> <isLastImage>false</isLastImage> <isNextImage>true</isNextImage> <firstImage>images/theresbenjamingualon.jpg</firstImage> <itemLargeImage> images/reuse.jpg</itemLargeImage> <nextImage>ewasteopening.jpg<nextImage> <nextThumbnail>ewasteopening.jpg</nextThumbnail> <prevImage>theresbenjamingualon.jpg </prevImage> <prevThumbnail>theresbenjamingualon.jpg</prevThumbnail> <lastImage>images/hp_laserjet_pro_m1213nf_aio___lr.jpg</lastImage> <lastThumbnail>thumbnails/hp_laserjet_pro_m1213nf_aio___lr.jpg</lastThumbnail> <itemWidth>468</itemWidth> <itemHeight>313</itemHeight> <itemThumbnailImage>thumbnails/someimagefile.jpg</itemThumbnailImage> <itemThumbnailWidth>90</itemThumbnailWidth> <itemThumbnailHeight> 64 </itemThumbnailHeight> <itemName>someimagefile.jpg</itemName> <itemNumber513</itemNumber> <itemOriginalPath>c:somefoldersomeimagefile.jpg</itemOriginalPath> <itemNameOnly> itemNameOnly UNDEFINED (9)</itemNameOnly> <itemCaption>someimagefile.jpg</itemCaption> <itemSize>itemSize UNDEFINED (9)</itemSize> </image>
In all of this we only need the the <itemThumbnailImage>, <itemLargeImage>, and <itemName>. We can use the caption as well, but for our simple example we will avoid it.
You can download a free trial of Adobe Flash Builder 4 from the Adobe website.

|
|
| xml, adobe, adobe flash, flash, picasa, flex, flash builder, actionscript, flash builder 4 |

