views:

346

answers:

1

I'm fading out a Bitmap in AS3 by repeatedly applying a ColorTransform every frame to its BitmapData;

_bitmap.colorTransform(_bitmap.rect, new ColorTransform(1, 1, 1, .9, 0, 0, 0, 1));

When applying the apparent reverse to fade it back in I get a discoloured image.

_bitmap.colorTransform(_bitmap.rect, new ColorTransform(1, 1, 1, 1.1, 0, 0, 0, 1));

The problem appears to occur only to fully faded-out images. If I only go part way it is recoverable.

fading out:

AS3 ColorTransForm Fading out

faded back

AS3 ColorTransform problem

+1  A: 

I would guess that this is due to destructively changing the bitmap data. Try retaining the original data, and applying your transform fresh on every frame, or alternatively wrapping the bitmap in a Sprite and applying the color transform onto that instead.

NS1