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
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
Sorry 'bout that, I usually am in the habit of saving for MX…try this one:
It looks like this:
Adam
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
Hi Gorilla! yeah, that is done with tweening tho, I don’t see much problem converting the same theme to actioscript.