# XML Image Gallery - Controlling Alpha Effect for Dynamic Images

**URL:** <https://forum.kirupa.com/t/xml-image-gallery-controlling-alpha-effect-for-dynamic-images/206028>\
**Category:** flash\
**Created:** [November 4, 2006, 7:33am UTC](https://forum.kirupa.com/t/xml-image-gallery-controlling-alpha-effect-for-dynamic-images/206028 "2006-11-04T07:33:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![meetmurali](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@meetmurali](https://forum.kirupa.com/u/meetmurali)\
**Post date:** [November 4, 2006, 7:33am UTC](https://forum.kirupa.com/t/xml-image-gallery-controlling-alpha-effect-for-dynamic-images/206028/1 "2006-11-04T07:33:37Z")

</div>

Hello All,

Below is the code for dynamic image gallery from XML.

We have an alpha effect to the image animation when the image is loading. The affect is working fine (fade in).

But, when the next image is loading, we want fade out alpha affect to the current image before the next image loads.

Any idea how to achieve this task? Below is the present code.

Regards

Krishhhhhhhhhh

delay = 6000;  
//-----------------------

function loadXML(loaded) {  
if (loaded) {  
xmlNode = this.firstChild;  
image = [];  
raname = [];  
description = [];  
link = [];  
total = xmlNode.childNodes.length;

//trace(tname.text);  
for (i=0; i\<total; i++) {  
image\* = xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue;  
raname\*= xmlNode.childNodes\*.childNodes[1].firstChild.nodeValue;  
description\* = xmlNode.childNodes\*.childNodes[2].firstChild.nodeValue;  
link\* = xmlNode.childNodes\*.childNodes[3].firstChild.nodeValue;  
//trace(link\*);  
}  
firstImage();  
} else {  
content = “file not loaded!”;  
}  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
[//xmlData.load](https://xmlData.load)(\_global.server+“images.php”);  
xmlData.load(“images.xml”);  
[//xmlData.load](https://xmlData.load)(“images.php”);  
/////////////////////////////////////  
//play\_btn.\_visible = 0;  
pause\_btn.onRelease = function() {  
clearInterval(myInterval);  
// pause\_btn.\_visible = 0;  
play\_btn.\_visible = 100;  
};  
play\_btn.onRelease = function() {  
myInterval = setInterval(pause\_slideshow, delay);  
pause\_btn.\_visible = 100;  
//play\_btn.\_visible = 0;  
};  
/////////////////////////////////////  
p = 0;  
this.onEnterFrame = function() {  
filesize = picture.getBytesTotal();  
loaded = picture.getBytesLoaded();  
preloader.\_visible = true;  
if (loaded != filesize) {  
preloader.preload\_bar.\_xscale = 100\*loaded/filesize;  
} else {  
preloader.\_visible = false;

\*\* if (picture.\_alpha\<100) {  
picture.\_alpha += 3;  
}  
\*\*

}  
};  
//////////////////////////////////  
function nextImage() {  
pause\_btn.\_visible = 100;  
//play\_btn.\_visible = 0;  
if (p\<(total-1)) {  
p++;  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
desc\_txt.text = description[p];  
rname.text = raname[p];  
//trace(rname.text);

nlink=link[p];  
slideshow();  
//trace (picture.\_alpha)  
}  
}  
}  
function prevImage() {  
if (p\>0) {  
p–;  
picture.\_alpha = 0;  
picture.loadMovie(image[p], 1);  
rname.text = raname[p];  
//trace(rname.text);  
desc\_txt.text = description[p];  
nlink=link[p];  
picture\_num();  
}  
}  
function firstImage() {  
if (loaded == filesize) {  
picture.\_alpha = 0;  
picture.loadMovie(image[0], 1);  
rname.text = raname[0];  
//trace(rname.text);  
desc\_txt.text = description[0];  
nlink=link[0];  
slideshow();  
}  
}  
function picture\_num() {  
current\_pos = p+1;  
pos\_txt.text = current\_pos+" / "+total;  
}  
function slideshow() {  
myInterval = setInterval(pause\_slideshow, delay);  
function pause\_slideshow() {  
clearInterval(myInterval);  
if (p == (total-1)) {  
p = 0;  
firstImage();  
} else {  
nextImage();  
}  
}  
}  
function pause\_slideshow() {  
clearInterval(myInterval);  
if (p == (total-1)) {  
p = 0;  
// firstImage();  
} else if (p == total) {  
gotoAndPlay(“credits”, 1);  
} else {  
nextImage();  
}  
}
