View Full Version : color tint?
axiomflash
01-22-2008, 11:08 PM
In the Flash IDE, it is really simple to tint a movieclip to the right color you want. Select the clip, set the color property to Tint and choose the percent of Tint Amount you want.
However, there seems to be no way to apply Tint Amount is AS3. I'm sure there is some way to do this through a complex formula of rgb offsets, but i can't figure it out. it blows my mind that this property exists in the IDE, but not actionscript.
Does anyone know a solution?
Flassari
01-22-2008, 11:49 PM
Just use colorTransform.
var resultColorTransform:ColorTransform = new ColorTransform();
resultColorTransform.alphaMultiplier = 0.5;
resultColorTransform.redOffset = 155;
resultColorTransform.greenMultiplier = 0.5;
myToBeTintedDisplayObject.transform.colorTransform = resultColorTransform;
Taken from the adobe docs for the transform property (http://livedocs.adobe.com/flex/201/langref/flash/display/DisplayObject.html#transform)
Flassari
01-23-2008, 06:15 PM
If you want to completely tint the clip red, you would set all the color multipliers to zero (except alpha) and raise the red offset to 255 (0xFF).
Say for example you want the clip tinted to #AA2299, then the color offsets would be 0xAA for red, 0x22 for green, and 0x99 for blue, alpha tint would be 1 and all color multipliers would be zero.
axiomflash
01-23-2008, 06:30 PM
sweet, thanks, that's a huge help.
one question then, is what if i wanted to go HALFWAY to 0xAA2299?
thanks for the quick response too!
GdabZ
03-05-2008, 11:33 AM
I'm also interested in the possibility to set an amount for a tint. :confused:
panel
03-05-2008, 12:57 PM
Here (http://www.actionscript.org/forums/showthread.php3?t=160381&highlight=tint)
Here (http://www.actionscript.org/forums/showthread.php3?t=160381&highlight=tint)
In summary, basically if you want to have advanced control for things like this, you need to write your own class.. Flash's GUI doesn't translate into straightforward code in many cases
GdabZ
03-05-2008, 03:16 PM
Thank you ! ;)
I've solved the problem setting the color.alphaMultiplier of my dynamically tinted shape to 0.6, with the same solid shape pasted in place and arranged to back. :p
weaksauce
03-05-2008, 03:18 PM
A method I used for this was to add a shape to the stage with x, y, width and height properties equivalent to that of the object I wanted to tint, and then you can adjust the fill color and alpha as you see fit. Obviously, this will only work for rectangular objects.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.