PDA

View Full Version : alpha not increasing


jonBarzini
03-15-2007, 10:07 PM
Hello everyone,

I am new to this forum and sort of new to actionscript.

My question is that I have this prototype:

MovieClip.prototype.easeFade = function(targetAlpha, easing)
{
this.onEnterFrame = function()
{
if (Math.round(this._alpha) == Math.round(targetAlpha)) {
this._alpha = targetAlpha;
delete this.onEnterFrame;
}
else {
var va:Number = (targetAlpha - this._alpha) * easing;
this._alpha += va;
}
};
};


when i set targetAlpha to 0, everything works fine and the onEnterFrame is deleted. but when i set the targetAlpha to 100 the this._alpha never reaches 100 so the onEnterFrame is never deleted and continues forever.

Any help would be much appreciated.

Thanks

p.s. this is also my first time posting on any forum. If i did something wrong please let me know.

WhidbeyTomas
03-17-2007, 09:12 PM
I can't resist these childless posts. I don't know the answer to your question. And I have no business having an opinion, but sometimes a stupid response will spur an intelligent one. Let's give it a try.

As you imply, the problem lies with your strategy that prevents alpha from reaching 100%. What if you experimented with a lower percent? If you must have 100%, I am guessing you will want to try a different strategy than math.round.

PS: The only thing you might do different with your next post is to highlight your code and click on the # icon. It just makes reading code a little easier.

jonBarzini
03-17-2007, 11:31 PM
Thanks , it does work with a lower percent, right now i am passing .07 for easing. when i set targetAlpha to 0 it works fine, but when the value of targetAlpha is 100 the condition is never met to delete the onEnterFrame.