# Fade script

**URL:** <https://forum.kirupa.com/t/fade-script/18029>\
**Category:** flash\
**Created:** [April 12, 2003, 10:17am UTC](https://forum.kirupa.com/t/fade-script/18029 "2003-04-12T10:17:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![biscuit](https://avatars.discourse-cdn.com/v4/letter/b/f17d59/32.png) [@biscuit](https://forum.kirupa.com/u/biscuit)\
**Post date:** [April 12, 2003, 10:17am UTC](https://forum.kirupa.com/t/fade-script/18029/1 "2003-04-12T10:17:43Z")

</div>

I left my brain at the pub last night and now I can’t make this easy peasy script work.

I have two buttons and an MC.

Button one fades the MC in  
Button two fades the MC out.

Here’s my fade function

function alphaFade(dir, whichClip, rate){  
if(dir== true){

```
	_root[whichClip]._alpha = _root[whichClip]._alpha+rate;
}
if(dir == false){
	

	_root[whichClip]._alpha = _root[whichClip]._alpha-rate;
}

```

}

For some reason you can fade the MC in but the other button fails to fade it out. ( I also tried it the other way round ie. different starting alpha)

Please help. Thanks in advance.

---

<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:** [April 12, 2003, 10:33am UTC](https://forum.kirupa.com/t/fade-script/18029/2 "2003-04-12T10:33:18Z")

</div>

button 1

```auto
on (release) {
	mymovieclip.onEnterFrame = function() {
		(this._alpha>99) ? delete this.onEnterFrame : this._alpha++;
	};
}

```

button 2

```auto
on (release) {
	mymovieclip.onEnterFrame = function() {
		(this._alpha<1) ? delete this.onEnterFrame : this._alpha--;
	};
}

```

:beam:

---

<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:** [April 12, 2003, 10:36am UTC](https://forum.kirupa.com/t/fade-script/18029/3 "2003-04-12T10:36:26Z")

</div>

That’ll be the one! Cheers! I need help with just about everything today!

Thanks for your swiftness Ahmed. 🙂
