# Fading MC with AS

**URL:** <https://forum.kirupa.com/t/fading-mc-with-as/34754>\
**Category:** Uncategorized\
**Created:** [November 6, 2003, 12:58am UTC](https://forum.kirupa.com/t/fading-mc-with-as/34754 "2003-11-06T00:58:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![macneilslt](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@macneilslt](https://forum.kirupa.com/u/macneilslt)\
**Post date:** [November 6, 2003, 12:58am UTC](https://forum.kirupa.com/t/fading-mc-with-as/34754/1 "2003-11-06T00:58:05Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2003, 1:17am UTC](https://forum.kirupa.com/t/fading-mc-with-as/34754/2 "2003-11-06T01:17:27Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2003, 1:19am UTC](https://forum.kirupa.com/t/fading-mc-with-as/34754/3 "2003-11-06T01:19:04Z")

</div>

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

```auto
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;
	};
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 6, 2003, 1:22am UTC](https://forum.kirupa.com/t/fading-mc-with-as/34754/4 "2003-11-06T01:22:51Z")

</div>

thanks EG/catbert
