Reputation: 861
I have a container movieclip that's white. At the end of my game, I want the movieclip to turn black but gradually, creating an image effect from white to black. Basically I want the movieclip to darken and keep darkening until the movieclip is completely black, and then the darkening stops. Any ideas on how to accomplish this?
Upvotes: 1
Views: 546
Reputation: 13510
You can try a color transform.
var fade:Number = 1.0;
var fadeAmount:Number = 0.01;
var timer:Timer = new Timer(33);
timer.addEventListener(TimerEvent.TIMER, darken);
timer.start();
function darken(e:TimerEvent):void
{
fade -= fadeAmount;
if(fade < 0.0) {
fade = 0.0;
timer.stop();
}
movieClip.transform.colorTransform = new ColorTransform(fade, fade, fade, 1.0, 0, 0, 0, 0);
}
Upvotes: 4
Reputation: 359
Well, you can try and use TweenLite to tween the colors, but that is expensive in memory terms.
Or, you can try this "hack" (never tried, so I don't the result) - create two sprites that will cover the screen, the top one white, under it - the black one. Set the alpha of the black to 0, and the white 1. Then, in ENTER_FRAME gradually reduce the alpha of the white and increase the alpha of black until black has alpha 1. It should produce something similar of that you want...
Upvotes: 0