Hello,
I would like to fade in and out and object with the colorTransform-method.
When I apply the colorTransform to my object it does fade out the thing but not fade in.
At first I set the alpha of the bitmapData to 0 (for the fade in-effect). After applying the colorTransform it does nothing. No fade in.
Otherwise when I set the alpha of the bitmapData to 100 and let it fade out it works.
I don’t know where the error might be so is there anyone who might help me with this problem? Or do you know another method for achieving the same goal? Thank you very much for your help.
BTW: My object (tempScore) is no display object. It is blitted onto a canvas.
This is the function that shall colorTransform my object:
private function setAlpha(setMode:int, bmd:BitmapData):BitmapData
{
var rec:Rectangle = new Rectangle(0, 0, bmd.width, bmd.height);
var ct:ColorTransform = new ColorTransform();
if (setMode == 1) {
ct.alphaMultiplier = .95;
} else if (setMode == 2) {
ct.alphaMultiplier = 1.05;
} else if (setMode == 3) {
ct.alphaMultiplier = 0;
} else if (setMode == 4) {
ct.alphaMultiplier = .5;
} else if (setMode == 5) {
ct.alphaMultiplier = 1;
}
bmd.colorTransform(rec, ct);
return bmd;
}
This is the code where I’d like to change the alpha but the fade in doesn’t work:
setAlpha(2, tempScore.bitmapData);
This is the code where I set the alpha of the bitmapData to 0:
rec = new Rectangle(0, 0, $textWidth, $textHeight);
ct = new ColorTransform();
ct.alphaMultiplier = 0;
tempScore.bitmapData.colorTransform(rec, ct);