PURPOSE:These two prototypes are applied to a movieclip to fade it in/out independent of the movie timeline and frame rate. Upon fading out the movieclip's _visibility attribute is set to false.
PROTOTYPE:CODE
movieclip.prototype.fadeIn=function(a,s) {
if(typeOf(a)!="number") a=1;
if(typeOf(s)!="number") s=50;
if(!this._visible) this._visible=true;
if(this.gsbLoop) clearInterval(this.gsbLoop);
this.gsbLoop=setInterval( function() {
if((arguments[0]._alpha+=arguments[1])>=100) {
arguments[0]._alpha=100;
clearInterval(arguments[0].gsbLoop);
}
updateAfterEvent();
}, s, this, a );
};
movieclip.prototype.fadeOut=function(a,s) {
if(typeOf(a)!="number") a=1;
if(typeOf(s)!="number") s=50;
if(this.gsbLoop) clearInterval(this.gsbLoop);
this.gsbLoop=setInterval( function() {
if((arguments[0]._alpha-=arguments[1])<=0) {
arguments[0]._alpha=0;
arguments[0]._visible=false;
clearInterval(arguments[0].gsbLoop);
}
updateAfterEvent();
}, s, this, a );
};
USAGE: movieclip.fadeIn( amount, speed ); and movieclip.fadeOut( amount, speed );
Where: amount is the movieclip's _alpha property increment or decrement, and
speed is the number of milliseconds between changes.
EXAMPLE:CODE
movieclip.fadeIn( 1, 50 );