fadeOut a MovieClip in as2
The below code shows how to fadeOut a MovieClip
function fadeOut (mc:MovieClip, speed:Number):Void {
mc.onEnterFrame = function() {
if (mc._alpha>=0) {
mc._alpha -= speed;
} else {
delete mc.onEnterFrame;
}
};
};
fadeOut(myMovieClipInstance, 5);
You can also declare the same as protoType
MovieClip.prototype.fadeOut = function(speed:Number):Void {
this.onEnterFrame = function() {
if (this._alpha>=0) {
this._alpha -= speed;
} else {
delete this.onEnterFrame;
}
};
};
myMovieClipInstance.clip_mc.fadeOut(5);