fadeIn a MovieClip in as2

Posted by Vineela | Uncategorized | Wednesday 22 October 2008 3:42 am

The below code shows how to fadeIn a MovieClip


function fadeIn (mc:MovieClip, speed:Number):Void  {
    mc.onEnterFrame = function() {
        if (mc._alpha<100) {
            mc._alpha += speed;
        } else {
            delete mc.onEnterFrame;
        }
    };
};

fadeIn(myMovieClipInstance, 5);

You can also declare the same as protoType


MovieClip.prototype.fadeIn = function(speed:Number):Void  {
    this.onEnterFrame = function() {
        if (this._alpha<1000) {
            this._alpha += speed;
        } else {
            delete this.onEnterFrame;
        }
    };
};

myMovieClipInstance.clip_mc.fadeIn(5);