# Cross Fade?

**URL:** https://forum.kirupa.com/t/cross-fade/43034
**Category:** flash
**Created:** [February 18, 2004, 3:44am UTC](https://forum.kirupa.com/t/cross-fade/43034 "2004-02-18T03:44:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![gorilla1](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@gorilla1](https://forum.kirupa.com/u/gorilla1)
#### Post date: [February 18, 2004, 3:44am UTC](https://forum.kirupa.com/t/cross-fade/43034/1 "2004-02-18T03:44:01Z")

</div>

I am trying to do simultaneous cross fade of iamges in a slideshow. The script here seems to have a very elegant method for cross-fading movieclips:  
[http://www.actionscripts.org/showMovie.php?id=678](http://www.actionscripts.org/showMovie.php?id=678)  
However, I cannot get this script to work for images Anyone have a clue as to how to make this work with images? Let’s say I have done:  
this.createEmptyMovieClip(“photo”, 200)  
and done a loadmovie of an iamge into the the MC.  
Here is the actionscript that I want to alter so that it will cross fade the iamges…  
//  
// P i X E L W i T . C O M  
//  
//  
//  
//  
// Define variables.  
var step = 5;  
var xFadeDepth = 999;  
var oldClip;  
//  
//  
//  
//  
//  
//  
// Make a class to fade-out any clip.  
function fadeOut() {};  
fadeOut.prototype = new MovieClip();  
fadeOut.prototype.onEnterFrame = function() {  
this.\_parent.\_alpha -= step;  
if (this.\_parent.\_alpha\<=0) {  
this.\_parent.\_alpha = 0;  
this.\_parent.\_visible = false;  
this.removeMovieClip();  
}  
};  
// XOut is a blank clip in the library with  
// a linkage identifier of “XOut”.  
Object.registerClass(“XOut”, fadeOut);  
// Now any time you attach the XOut clip to  
// another clip, it will decrease that clip’s  
// alpha until it reaches 0 then set that clip’s  
// visibility to false and then remove itself.  
//  
//  
//  
//  
//  
//  
// Make a class to fade-in any clip.  
function fadeIn() {};  
fadeIn.prototype = new MovieClip();  
fadeIn.prototype.onLoad = function(){  
this.\_parent.\_visible = true;  
};  
fadeIn.prototype.onEnterFrame = function() {  
this.\_parent.\_alpha += step;  
if (this.\_parent.\_alpha\>=100) {  
this.\_parent.\_alpha = 100;  
this.removeMovieClip();  
}  
};  
// XIn is a blank clip in the library with  
// a linkage identifier of “XIn”.  
Object.registerClass(“XIn”, fadeIn);  
// Now any time you attach the XIn clip to  
// another clip it will increase that clip’s  
// alpha until it reaches 100 then remove itself.  
//  
//  
//  
//  
//  
//  
// XFade crossfades two clips.  
// NewClip is the clip to be revealed.  
// OldClip tracks the last revealed clip.  
function xFade(newClip) {  
if (newClip != oldClip) {  
newClip.attachMovie(“XIn”, “Fader”, xFadeDepth);  
oldClip.attachMovie(“XOut”, “Fader”, xFadeDepth);  
oldClip = newClip;  
}  
}  
//  
//  
//  
//  
//  
//  
// Hide all the clips to be crossfaded.  
Red.\_visible =  
Green.\_visible =  
Blue.\_visible =  
Yellow.\_visible =  
Red.\_alpha =  
Green.\_alpha =  
Blue.\_alpha =  
Yellow.\_alpha = 0;  
//  
//  
//  
//  
//  
//  
// Assign crossfade functions to buttons.  
RB.onRollOver = function (){  
xFade(Red);  
}  
GB.onRollOver = function (){  
xFade(Green);  
}  
BB.onRollOver = function (){  
xFade(Blue);  
}  
YB.onRollOver = function (){  
xFade(Yellow);  
}  
//  
//  
//  
//  
//  
//

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 18, 2004, 3:52am UTC](https://forum.kirupa.com/t/cross-fade/43034/2 "2004-02-18T03:52:08Z")

</div>

I did a minor alteration on a file I’d done for someone else if you want to see it:

> **[Yahoo Small Business - Cheap Domains, Web Hosting, Website Builder, Ecommerce...](https://smallbusiness.yahoo.com/)**
>
> Yahoo Small Business Offers Cheap Domain Names, Web Hosting, Easy Website Builder, Business Email, Local Listings, and Ecommerce Solutions for Your Small Business.

Looks like what you want.  
Adam
