home   |   about   |   time   |   appearance   |   space   |   other   |   tips & tricks    

Cool Fade In

Same Flash File, but this time we used the following code on the first Movie Clip:

onClipEvent( load ) {
	this._alpha = 0;
	var i:Number = 0;
}
onClipEvent( enterFrame ) {
	if( i > 30 )
		_parent.play();
	else {
		this._alpha=i*3-random(20);
		i++;
	}
}

As you can see in the file presented at the top of the page, we did another version of the fade. The effect is not smooth, but ruff (we used it various times in intros and banners) because the _alpha parameter grows randomly but within some limits. Let's explain the code.

this._alpha = 0;
// before playing the Clip is not visible
var i:Number = 0;
// we declare and initialize the variable "i" which will be used to control the transparency;

The idea is to increment "i" every time the Movie enters a new frame and to set the transparency to a random value between [3*i and 3*i-20]. We will stop the loop after 33 frames. Why 33? Because the _alpha parameter will be somewhere between 99 and 79 so we can pass to 100 without making any sudden visual change.

if( i > 33 )
	_parent.play(); // if the clip enters frame 30 it's time to stop
else {
	this._alpha = i * 3 - random(20);
	//if not we give another value to "_alpha"
	i++; // and increment "i"
}

That's about it. In the next chapter you will learn how to create the actual background for the flame effect.

Download .ZIP Download .FLA
< Simple Fade InFire Background >