# FadeIn FadeOut prototype

**URL:** https://forum.kirupa.com/t/fadein-fadeout-prototype/180296
**Category:** flash
**Created:** [February 27, 2006, 5:36pm UTC](https://forum.kirupa.com/t/fadein-fadeout-prototype/180296 "2006-02-27T17:36:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![coop](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coop](https://forum.kirupa.com/u/coop)
#### Post date: [February 27, 2006, 5:36pm UTC](https://forum.kirupa.com/t/fadein-fadeout-prototype/180296/1 "2006-02-27T17:36:44Z")

</div>

Hi all,

I use these prototypes for fading in and out stuff.

They work fine, but the fadeOut prototype only seems to work correctly when I use

this.onEnterFrame = null  
instead of  
this.onEnterFrame = null

Does any one know why this is so.

[AS]  
MovieClip.prototype.fadeIn = function(target, num, limit) {  
target.onEnterFrame = function() {  
this.\_alpha += num;  
if (this.\_alpha\>=limit) {  
this.\_alpha = limit;  
delete this.onEnterFrame;  
}  
};  
};

MovieClip.prototype.fadeOut = function(target, num, limit) {  
target.onEnterFrame = function() {  
this.\_alpha -= num;  
if (this.\_alpha\<=limit) {  
this.\_alpha = limit;  
this.onEnterFrame = null;  
}  
};  
};  
test\_mc.fadeOut(test\_mc, 20, 10);  
[/AS]
