XML Tree in Flash

To demonstrate the use of XML structure in Flash, I've created a simple photoalbum.

It relies on a .xml file where the images are listed. Request to load an images is send only when it's selected so no pre-loadig is needed.

There are three components used in Flash:

    1. Tree
    Used to display the XML structure. Scrollbar is also a part
    of this component. It automatically appears when needed.

    2. Loader
    Used to load a selected image. The size canbe specified to
    match current requirements.

    3. Progress bar
    Displays loading progress when an image is selected.

The look of all components can be customized by importing them into the library and changing their parts. To find from where to import, read 'About skinning components' from the Flash help.


Preview in new window >
Download the source code >

How it works

The XML structure was created by using <tree> and <node> elements. Paths to images must be specified either relativelly to the .swf file or by using a full URL.

There are several lines of code used in Flash to load the structure. The most imporant part is where the XML document is linked:

treeDP_xml.load
("gallery/gallery_tree.xml");


Where 'treeDP_xml' is a virtual XML structure inside Flash.

Indivdual attributes of a node can be accesed as following:

treeNode.attributes.src

Where 'treeNode' is defined as a selected node of the structure and 'src' is an attribute specifying where a jpeg file is saved.