you need XML to make this automatic, let me show you how;
xml: create an xml file with all your images and their description
HTML Code:
<?xml version='1.0' encoding='UTF-8'?>
<library>
<jpg>
<file>fotos/foto0.jpg</file>
<desc>Antigua</desc>
</jpg>
<jpg>
<file>fotos/foto1.jpg</file>
<desc>Flag's Emblem</desc>
</jpg>
<jpg>
<file>fotos/foto2.jpg</file>
<desc>Village</desc>
</jpg>
<jpg>
<file>fotos/foto3.jpg</file>
<desc>Mayan Girl</desc>
</jpg>
<jpg>
<file>fotos/foto4.jpg</file>
<desc>Lake Atitlan</desc>
</jpg>
</library>
flash: gallery is now based on the information from our xml file
ActionScript Code:
//: SETUP INITIAL VARIABLES
var oldVar = 0;
var newVar = 0;
var si = 0;
//: GET XML
var my_xml = new XML ();
my_xml.ignoreWhite = true;
my_xml.onLoad = function (success) {
if (success) {
library = this.firstChild.childNodes;
maxVal = library.length;
delete my_xml;
getImage ();
} else {
desc_txt.text = 'Error: XML Not Loaded';
}
};
my_xml.load ('library.xml');
//: LOAD THE NEXT IAMGE
function getImage () {
newVar = Math.floor (Math.random () * maxVal);
if (newVar == oldVar) {
getImage ();
} else {
oldVar = newVar;
container_mc.loadMovie (library[newVar].firstChild.firstChild.nodeValue);
container_mc._alpha = 0;
this.onEnterFrame = function () {
if (container_mc._width > 0) {
container_mc._x = Stage.width / 2 - container_mc._width / 2;
container_mc._y = Stage.height / 2 - container_mc._height / 2;
container_mc.onEnterFrame = fadeIn;
desc_txt.text = library[newVar].firstChild.nextSibling.firstChild.nodeValue;
delete this.onEnterFrame;
}
};
}
}
//: FADE IN THE CURRENT MOVIECLIP
function fadeIn () {
if (this._alpha <= 100) {
this._alpha += 5;
} else {
this._alpha = 100;
delete this.onEnterFrame;
si = setInterval (fadeOut, 2000);
}
}
//: FADE OUT THE CURRENT MOVIECLIP
function fadeOut () {
clearInterval (si);
container_mc.onEnterFrame = function () {
if (this._alpha >= 0) {
this._alpha -= 5;
} else {
this._alpha = 0;
delete this.onEnterFrame;
getImage ();
}
};
}
once you've designed your gallery in flash, all you need to do is edit the xml file to see your changes; no need to publish the swf file again.
good luck with your gallery,
sophistikat
+
learn more:
Introduction to XML in Flash
XML Object