Hi,
The following class I’ve coded fails to fade the MC on stage. Could someone explain why the code fails?
class FadeAlpha extends MovieClip {
private var alpha:Number = this._alpha;
private var visible:Boolean = this._visible;
public var alphaRate:Number;
public var mc:MovieClip;
//constructor left enpty, can use later.
public function FadeAlpha() {
fadeObj();
}
function fadeObj(mc:MovieClip, alphaRate:Number) {
mc.onEnterFrame = function() {
mc.alpha -= alphaRate;
if (mc.alpha<=0) {
mc._visible = false;
delete mc.onEnterFrame;
}
};
}
}
//From AS Timeline:
import FadeAlpha;
var fadeAlpha:FadeAlpha = new FadeAlpha);
img01_mc.fadeAlpha(this, 5);
On Stage:
img1_mc