Chris Porter
Chris Porter

Reputation: 2449

reverse colortransform alpha AS3

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
(source: ggpht.com)

faded back

AS3 ColorTransform problem
(source: ggpht.com)

Upvotes: 0

Views: 1294

Answers (1)

NS1
NS1

Reputation: 11

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.

Upvotes: 1

Related Questions