# Alpha fade mc via buttons

**URL:** https://forum.kirupa.com/t/alpha-fade-mc-via-buttons/178934
**Category:** flash
**Created:** [February 15, 2006, 3:18pm UTC](https://forum.kirupa.com/t/alpha-fade-mc-via-buttons/178934 "2006-02-15T15:18:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Blowfish](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blowfish/32/744_2.png) [@Blowfish](https://forum.kirupa.com/u/Blowfish)
#### Post date: [February 15, 2006, 3:18pm UTC](https://forum.kirupa.com/t/alpha-fade-mc-via-buttons/178934/1 "2006-02-15T15:18:19Z")

</div>

I was testing this code out but i didnt get it to work as i wanted.  
I have 4 mc in my \_root (mc\_clip1-mc\_clip4). Clip1 is at 100% alpha, the rest is hidden ( in this syntax i only have 2 clips)

Iw hidden the second clip,  
clip2.\_alpha = 0;

and function fadeIn is suppose 2 fade in clip 2  
and funktion fadeOut is suppose 2 fade out clip 1

BUT when i use these 2 lines,ony one funtion works

my\_mc.onRelease = fadeOut;  
my\_mc.onRelease = fadeIn;

how can i solve this problem? the thing is that i need 2 more clips (4 in total) that needs 2 be given functions so they can hide and show clips.

One button has 2 objectivs: hide the clip that is 100% alpha and show the target clip 0-100% alpha.

Realy hope that someone can help me

```php
 
clip2._alpha = 0;
 
Button.prototype.fadeIn = MovieClip.prototype.fadeIn = function () {
//trace("fadeIn called on "+this);
this.onEnterFrame = function () {
if (clip2._alpha<100) { 
//trace("fade-ing in! alpha = "+this._alpha);
clip2._alpha += 10;
} else {
delete this.onEnterFrame;
//trace("DONE! Ended on alpha "+this._alpha);
}
};
};
Button.prototype.fadeOut = MovieClip.prototype.fadeOut = function () {
//trace("fadeOut called on "+this);
this.onEnterFrame = function () {
if (clip1._alpha>0) {
//trace("fade-ing out! alpha = "+this._alpha)
clip1._alpha -= 10;
} else {
delete this.onEnterFrame;
//trace("DONE! Ended on alpha "+this._alpha);
}
};
};
 
my_mc.onRelease = fadeOut;
my_mc.onRelease = fadeIn;

```
