# Cross Fade?

**URL:** https://forum.kirupa.com/t/cross-fade/101943
**Category:** Uncategorized
**Created:** [February 18, 2004, 3:44am UTC](https://forum.kirupa.com/t/cross-fade/101943 "2004-02-18T03:44:01Z")
**Posts on this page:** 6
**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/101943/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/101943/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

---

<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 19, 2004, 1:01am UTC](https://forum.kirupa.com/t/cross-fade/101943/3 "2004-02-19T01:01:10Z")

</div>

Adam14,

Thanks a ton! Unfortunately, I get “unexpected file format” when I try to open it (I tried both flash mx and flash 5). Any chance you have the file in flash mx format or could just paste the actionscript here on the forum? Thanks again.

G

---

<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 19, 2004, 1:48am UTC](https://forum.kirupa.com/t/cross-fade/101943/4 "2004-02-19T01:48:09Z")

</div>

Sorry 'bout that, I usually am in the habit of saving for MX…try this one:

> **[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.

It looks like this:

> **[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.

Adam

---

<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 19, 2004, 2:42am UTC](https://forum.kirupa.com/t/cross-fade/101943/5 "2004-02-19T02:42:24Z")

</div>

Thanks, Adam14 – awesome… However, I really was looking to do the fade action in actionscript rather than with a twee - if I understand this fla right, the fade is done in the tween. But thanks.

G

---

<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 19, 2004, 4:08am UTC](https://forum.kirupa.com/t/cross-fade/101943/6 "2004-02-19T04:08:47Z")

</div>

Hi Gorilla! yeah, that is done with tweening tho, I don’t see much problem converting the same theme to actioscript.
