PDA

View Full Version : fading in order


utswim
10-25-2002, 08:51 PM
After the .swf opens with a pause on black, I'm trying to make a logo fade in, hold for a second, fade out, hold again on black, then make a new image (the bg) fade in and hold, then fade to about alpha 25, when new clips and buttons are introduced over the faded bg.

I've accomplished the initial fading in using this programmed in the movie clip:

onClipEvent (load) {
this._alpha = 0;
}
onClipEvent (enterFrame) {
this._alpha += 10;
}

That's as far as I've gotten. The guess and check method doesn't work to well on this one.

Can I do all of the above on one frame, or do I need multiple frames. I think this may be a variation of a slide show, but I'm not sure how to do that either. What type of code does this require, and where (main timeline, within movie clip, etc.)? Any help is much appreciated, I turning grey over this.

Thanks.

Ricod
10-26-2002, 11:08 AM
Well, I think that a nice fade function would be handy here (excuse my old coding, I'm OOP unfamilair) :
function faderFunction(targetClip) {
var targetAlpha = 25; // not necesary in this case, but just clearer
if (_root[targetClip].fadeStage == " fadeIn") {
_root[targetClip]._alpha += 10;
if (_root[targetClip]._alpha == 100) {
_root[targetClip].fadeStage = "fadePause";
_root[targetClip].startTime = getTimer();
}
}else if (_root[targetClip].fadeStage == " fadePause" ) {
var currentTime = getTimer();
if (currentTime >= _root[targetClip].startTime + 1000){
_root[targetClip].fadeStage = "fadeOut";
}
}else if (_root[targetClip].fadeStage == " fadeOut" ) {
if (_root[targetClip]._alpha > targetAlpha) {
_root[targetClip]._alpha -= 5;
} else if (_root[targetClip]._alpha == targetAlpha) {
_root[targetClip].fadeStage = "Done";
}
the clips could have something like :
onClipEvent (load) {
this._alpha = 0;
this.fadeStage = "fadeIn";
}
onClipEvent (enterFrame) {
if (this.fadeStage != "Done"){
_root.faderFunction("myClip.itsChild"); //targetClip = _root.myClip.itsChild, ofcourse change where appropriate
}
}

Hope this helps ya ! If anything is unclear why its there ... just ask away ! (that's the important part)

Annika
10-26-2002, 03:36 PM
Hello!
You have already got great code in the above example but I just wanted to share another solution.
Instead of writing a script you could do it all in a separate movieclip and then put it on your stage...

Annika

Ricod
10-26-2002, 03:41 PM
Yes, that would also work !

But if you have a lot of the same fades, you're giving yourself more work than nescesary. But if you only have a few, this can indeed be faster, specially if you're going to have different fade times depending on the clip etc. or different fade-directions etc.

utswim
10-28-2002, 02:54 PM
Thank you all VERY much for your help. I attached a script to each MC, with a true/false execution upon completion of the fade. The next doesn't begin until the previous reads true. Easy to duplicate and tweak for many fades.