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
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);
}
//
//
//
//
//
//
I did a minor alteration on a file I’d done for someone else if you want to see it:
Looks like what you want.
Adam