PDA

View Full Version : Cross Fade?



gorilla1
February 17th, 2004, 10:44 PM
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);
}
//
//
//
//
//
//

Adam
February 17th, 2004, 10:52 PM
I did a minor alteration on a file I'd done for someone else if you want to see it:

http://www.geocities.com/yellowraincoatman/Gorilla1.fla

Looks like what you want.
Adam

gorilla1
February 18th, 2004, 08:01 PM
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

Adam
February 18th, 2004, 08:48 PM
Sorry 'bout that, I usually am in the habit of saving for MX...try this one:

http://www.geocities.com/yellowraincoatman/Gorilla2.fla

It looks like this:

http://www.geocities.com/yellowraincoatman/Gorilla2.html

Adam

gorilla1
February 18th, 2004, 09:42 PM
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

Adam
February 18th, 2004, 11:08 PM
Hi Gorilla! yeah, that is done with tweening tho, I don't see much problem converting the same theme to actioscript.

geod100
October 16th, 2004, 11:17 PM
Hi -- I'm only on Flash 5 and I cannot open this file. Working with timeline tweens is fine...but I have no idea how you did this. Please help?