# Fade In Fade Out

**URL:** <https://forum.kirupa.com/t/fade-in-fade-out/313465>\
**Category:** flash\
**Created:** [August 31, 2010, 2:10pm UTC](https://forum.kirupa.com/t/fade-in-fade-out/313465 "2010-08-31T14:10:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ratanjaiswal](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@ratanjaiswal](https://forum.kirupa.com/u/ratanjaiswal)\
**Post date:** [August 31, 2010, 2:10pm UTC](https://forum.kirupa.com/t/fade-in-fade-out/313465/1 "2010-08-31T14:10:26Z")

</div>

I have been using this code for draggable slideshow I have modified the script for the images with fade in and fadeout effect as it comes and goes but not working well can any help me to modify the code

stop();  
import mx.transitions.Tween;  
import mx.transitions.easing.\*;

var picSpace = 2000;  
var minDist = 6;  
var picArray = new Array();  
var picTotal = 8;  
var holder = this.createEmptyMovieClip(“holder”, 0);  
holder.\_y = 50;  
function doLoadInit(mc) {  
var xOffset = 0;  
for (i = 0; i \< picTotal; i++) {  
holder\*.\_x = xOffset;  
picArray\*[1] = {x1:holder\*.\_x, x2:holder\*.\_x + holder\*.\_width};  
xOffset += holder\*.\_width + picSpace;  
//trace(holder\*);  
}  
mc.onPress = doPress;  
}  
function loadXML(loaded) {  
if (loaded) {  
var xmlNode = this.firstChild;  
picTotal = xmlNode.childNodes.length;  
for (i = 0; i \< picTotal; i++) {  
var picInfo = [xmlNode.childNodes\*.childNodes[0].firstChild.nodeValue];  
var p = holder.createEmptyMovieClip(i, i);  
my\_mcl.loadClip(picInfo[0], p);  
picArray.push(picInfo);  
}  
} else {  
content = “file not loaded!”;  
}  
delete xmlNode;  
}  
xmlData = new XML();  
xmlData.ignoreWhite = true;  
xmlData.onLoad = loadXML;  
xmlData.load(“dragthrow.xml”);  
var my\_mcl = new MovieClipLoader();  
var myListener = new Object();  
myListener.onLoadInit = doLoadInit;  
my\_mcl.addListener(myListener);  
//   
//holder.\_alpha = 0; // Start image clip as invisible

function doPress() {  
var idex = Number(this.\_name);  
var anchorX = holder.\_xmouse;  
var pressX = \_root.\_xmouse;  
holder.onEnterFrame = function() {  
this.\_x = \_root.\_xmouse - anchorX;  
};  
holder.onMouseUp = function() {  
var dist = \_root.\_xmouse - pressX;  
var dir = (dist \> 0) ? 0 : 1;  
dist = Math.abs(dist);  
if (dist \> minDist) {  
var endX = ((dir == 0) ? Stage.width - picArray[idex][1].x2 : 0 - picArray[idex][1].x1) - this.\_x;  
if (dir == 0 && endX \< 0 && idex \> 0) {  
var pictureTweenIn:Tween = new Tween (holder,"\_alpha",Normal.easeOut,0,100,1,true); // Use the Tween class to ease in the alpha from 0 to 100 over 1 seconds  
endX = (Stage.width - picArray[idex - 1][1].x2) - this.\_x;  
}  
if (dir == 1 && endX \> 0 && idex \< picTotal - 1) {  
var pictureTweenOut:Tween = new Tween (holder,"\_alpha",Normal.easeIn,0,100,1,true); // After pause, start fade out  
endX = (0 - picArray[idex + 1][1].x1) - this.\_x;  
}  
var begX = this.\_x;  
var d = (dist \> 60) ? (dist \> 180) ? 20 : 40 : 80;  
var tc = 0;  
this.onEnterFrame = function() {  
var t = ++tc;  
this.\_x = endX \* ((t = t / d-- - 1) \* t \* t + 1) + begX;  
if (tc == d) {  
delete this.onEnterFrame;  
}  
};  
} else {  
trace("selected: " + idex);  
delete this.onEnterFrame;  
}  
delete this.onMouseUp;  
};  
}

the in the xml file i am using

\<?xml version=“1.0” encoding=“utf-8” standalone=“yes”?\>  
\<images\>  
\<pic\>  
\<image\>images/comp1.swf\</image\>  
\<title\>PICTURE TITLE 1\</title\>  
\<caption\>Here is the caption.\</caption\>  
\<url\>[www.flashkit.com](http://www.flashkit.com)\</url\>  
\</pic\>  
\<pic\>  
\<image\>images/comp2.swf\</image\>  
\<title\>PICTURE TITLE 2\</title\>  
\<caption\>Here is the caption.\</caption\>  
\<url\>[www.flashkit.com](http://www.flashkit.com)\</url\>  
\</pic\>  
\<pic\>  
\<image\>images/comp3.swf\</image\>  
\<title\>PICTURE TITLE 3\</title\>  
\<caption\>Here is the caption.\</caption\>  
\<url\>[www.flashkit.com](http://www.flashkit.com)\</url\>  
\</pic\>  
\<pic\>  
\<image\>images/comp4.swf\</image\>  
\<title\>PICTURE TITLE 4\</title\>  
\<caption\>Here is the caption.\</caption\>  
\<url\>[www.flashkit.com](http://www.flashkit.com)\</url\>  
\</pic\>  
\<pic\>  
\<image\>images/comp1.swf\</image\>  
\<title\>PICTURE TITLE 5\</title\>  
\<caption\>Here is the caption.\</caption\>  
\<url\>[www.flashkit.com](http://www.flashkit.com)\</url\>  
\</pic\>  
\<pic\>  
\<image\>images/comp3.swf\</image\>  
\<title\>PICTURE TITLE 6\</title\>  
\<caption\>Here is the caption.\</caption\>  
\<url\>[www.flashkit.com](http://www.flashkit.com)\</url\>  
\</pic\>  
\</images\>
