My new friend setTint

I played around today with a method named setTint from the fl.motion.Color class. At first I was a bit confused because this method doesn’t return anything contrarily to the interpolateColor method which returns a color in hexadecimal. You have to use setTint in this way:

1
2
3
4
5
import fl.motion.Color;
import flash.geom.ColorTransform;
var ct:Color = new Color();
ct.setTint(0xFF0000, 0.5);
mc.transform.colorTransform = ct;

With mc being the displayObject you want it applied on. setTint can be pretty useful for setting a tint on a bitmap and it can also be used with tweens in the same way I used the interpolateColor in a previous post.

, , , ,

  1. #1 by Bruno - May 7th, 2008 at 14:03

    hello
    thank you very much for this tip. i will use to it to recreate my web site.

  2. #2 by James R Grise - January 20th, 2009 at 02:13

    nice, thanks. spent 20 minutes trying to apply setTint directly to my object haha, step back a sec and look at how sombody else does it and the whole function clicks. Thanks you saved me at least another 20 minutes.

  3. #3 by yac - August 1st, 2009 at 19:59

    Thanks for that.

    In my case I have a dropShadow filter applyed to the dyn.TextField, and when I cuse this colorTransform method it loses its dropShadow effect.

    Do anybody knows why that happens?

  4. #4 by yac - August 2nd, 2009 at 11:40

    the problem is that the shadow gets white too, with the color Transform.

    I’ve applied the dropShadow to a parent movieclip that contains only the textfield and that solves the problem.

    thanks !

  5. #5 by polo90 - October 27th, 2011 at 20:02

    Spent some time googling a simple way to do tinting. This is exactly what I’m looking for. Thanks!

(will not be published)
Subscribe to comments feed
  1. No trackbacks yet.