Hey,
I know this question has been asked a thousand times already, but I simply can’t get it to work.
I’ve looked at various other threads posts, but none of them seem to work.
Here’s what I’m trying to do:
I have a button (Instance name: “go”) and a MC (instance name: “fader”).
Now, I want the MC to fade in on rollOut and fade out on rollOut.
Currently, I have this code:
In frame 1 of my movie: (taken from this thread)
[AS]
Math.LT = function(t,b,c,d){
return c*t/d +b;
};
MovieClip.prototype.fade = function(startVal, endVal, speed) {
this.begin = startVal;
this.finish = endVal;
this.change = this.finish - this.begin;
this.duration = speed;
this.time = 0;
this.onEnterFrame = function(){
with (this) {
_alpha = math.LT(time++, begin, change, duration);
if (time > duration) delete this.onEnterFrame;
}
};
};
stop();
**In my button:**
on(rollOver)
{
fader.fade(0,100,5);
}
on(rollOut)
{
fader.fade(100,0,5);
}
But, like I said before, this does not work.
Note that just using "fader._alpha=<value>" in the rollOver/Out functions *does* work.
I've also tried it via the OnEnterFrame event, and that doesn't work either:
on(release)
{
fader.OnEnterFrame=function(){
_alpha-=5;
if(_alpha<=0)
delete OnEnterFrame;
}
}
Any ideas? :)