Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AS3 Tint Bitmap

I have a spritesheet for a project I am working on and I need to be able to change the tint of the image so I can se space. The image has some simple texture on it but it will be displayed in 5 different colors. I attached an image to see exactly what I am talking about: http://i42.tinypic.com/29443l5.png

I tried to achieve my desired effect using this on the resulting sprite:

var c:ColorTransform = new ColorTransform();
c.color = 0xf30909;
transform.colorTransform = c;

But I get everything red, not as I want. I am building for AIR so the package fl.motion.Color can't be imported (or at least Flash Builder 4.5 does not have it). Any idea on how I can achieve the desired effect? Thanks.

like image 802
Petre Popescu Avatar asked Jul 11 '26 00:07

Petre Popescu


2 Answers

Just for the sake of completeness...

public function Tint(display:DisplayObject, color:uint) {
    display.transform.colorTransform = new ColorTransform(color >> 16 & 0x0000FF / 255, color >> 8 & 0x0000FF / 255, color & 0x0000FF / 255);
}
like image 149
Jorjon Avatar answered Jul 13 '26 16:07

Jorjon


The color property sets the offset, i.e. it makes the ColorTransform add the color value to your image. You probably want to use the Multiplier properties. See ColorTransform documentation.

like image 42
Staven Avatar answered Jul 13 '26 17:07

Staven



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!