an image gallery:
the code gets an xml file with a list of image nodes, each image has a thumbnail path, a big image path, and a description.
The swf gets the xml file and makes 3 arrays, an array of the descriptions, an array of the thumb paths, an array of the big paths. The arrays are such that thumb[0] and description[0] and big[0] all relate to the same image.
I loop through the thumbs path array and put all the thumbs in place.
I put a bunch of invisible buttons over the thumbs, and put the button names into an array.
when button[0] is pressed (which is over thumb[0]) big[0] is displayed in the main window and description[0] is displayed below it.
Full code:(let me know if u have any q’s)
import mx.transitions.Tween;
import mx.transitions.easing.*;
var theXML:XML = new XML();
theXML.ignoreWhite = true;
var big_path:Array = new Array();
var thumb_path:Array = new Array();
var description:Array = new Array();
theXML.onLoad = function()
{
var images:Array = this.firstChild.childNodes;
var i:Number = 0;
//make the three arrays
for(i = 0; i < images.length; i++)
{
thumb_path.push(images*.attributes.thumb_path);
big_path.push(images*.attributes.big_path);
description.push(images*.attributes.description);
}
//make the array thumbnail holders
var thumbs:Array = new Array();
for (i = 0; i < description.length; i++)
{
thumbs*=root.slider_mc["thumb"+ i + “_mc”];
}
for (i = 0; i < description.length; i++)
{
root.slider_mc["button" + i + “_mc”].id = i;
root.slider_mc["button" + i + “_mc”].onRelease = function()
{
var fade_out:Tween = new Tween(big_image_mc, “_alpha”, easeOut, 100, 0, 1, true);
setTimeout(traceDescription, 1000, this.id);
};
}
function traceDescription(itemID)
{
description_txt.text = description[itemID];
big_image_mc.loadMovie(big_path[itemID]);
var fade_in:Tween = new Tween(big_image_mc, “_alpha”, easeOut, 0, 100, 1, true);
}
var $time:Number = 0.2;
//put the images into the thumb holders
for(i = 0; i < 10; i++)
{
thumbs*.loadMovie(thumb_path*);
var fade_in:Tween = new Tween(thumbs*, "_alpha", easeOut, 0, 100, $time, true);
$time = $time + 0.2;
}
big_image_mc.loadMovie(big_path[0]);
var fade_in:Tween = new Tween(big_image_mc, "_alpha", easeOut, 0, 100, .5, true);
description_txt.text = description[0];
arrow1_mc.onPress = function()
{
var slide:Tween = new Tween(slider_mc, "_y", easeOut, slider_mc._y, (slider_mc._y + 90), 1, true);
}
arrow2_mc.onPress = function()
{
var slide:Tween = new Tween(slider_mc, "_y", easeOut, slider_mc._y, (slider_mc._y - 90), 1, true);
}
}
theXML.load(“xml/gallery.xml”);