Fading MC with AS

i know voets posted something on this once, but i can’t find it using search, i tried several key words…

but what i was wanting to know, was how to alpha fade a MC with AS?

so if you mouse over it would start at 25 then go to 100, and on mouse out it would go back to 25

or something like that…

Hi,

you could use something like this in the frame that contains the movie clip

[AS]
function fadeClip() {
this._alpha += (this.destAlpha - this._alpha) / 5;
if (Math.round(this._alpha) == this.destAlpha) {
delete this.onEnterFrame;
}
}

instanceNameOfClip._alpha = 25;
instanceNameOfClip.onRollOver = function() {
this.destAlpha = 100;
this.onEnterFrame = fadeClip;
};
instanceNameOfClip.onRollOut = function() {
this.destAlpha = 25;
this.onEnterFrame = fadeClip;
};
[/AS]

Here’s another way, place it on your movieclip.

onClipEvent (load) {
	this._alpha = 25;
}
onClipEvent (enterFrame) {
	function fadeOut() {
		if (this._alpha>25) {
			this._alpha -= 10;
		} else {
			this.onEnterFrame = null;
		}
	}
	function fadeIn() {
		if (this._alpha<100) {
			this._alpha += 10;
		} else {
			this.onEnterFrame = null;
		}
	}
	this.onRollOver = function() {
		this.onEnterFrame = fadeIn;
	};
	this.onRollOut = function() {
		this.onEnterFrame = fadeOut;
	};
}

thanks EG/catbert