Hi all,
I’m fairly new to the AS world and am struggling to get something to work. What I’m trying to achieve is this: there’s a slideshow that automatically changes pictures every 10 secs (I’ve used a kirupa tutorial to achieve this). The pictures are loaded from an xml file, which also contains captions for the pictures. What I would like to do is to have the caption fade in and slightly move to the left with each picture change. E.g. picture 1 is displayed, caption 1 fades in, moves to the left and stays there; picture 2 is displayed, caption 2 fades in, moves to the left and stays there, and so on.
Below you’ll find the actionscript I have for now. It changes the pictures and displays all captions at once. If there’s anyone there who can help me create a fade in and a movement for the captions, I would really appreciate the help.
Regards,
Joris
import mx.transitions.Tween;
import mx.transitions.easing.*;
delay = 10000;
var descItems_mc:MovieClip = this.createEmptyMovieClip("di", this.getNextHighestDepth()); // holds small news items
descItems_mc._x = 50;
descItems_mc._y = 30;
//-----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
var ni_d:MovieClip = descItems_mc.attachMovie("desc_mc", "ni_d" + i, descItems_mc.getNextHighestDepth(), {_y:i * 50});
ni_d.desc_txt.text = description*;
ni_d.id = i;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = false;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
slideshow();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
slideshow();
}
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
}