Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Jeremy Rudd

TintPlugin vs HexColorsPlugin

Recommended Posts

Hi,

 

What is the difference between TintPlugin and HexColorsPlugin?

 

HexColors says it tweens colors so they "look correct", does tint plugin use a dumber version of the same?

 

Thanks

Link to comment
Share on other sites

The only difference is that the TintPlugin is only for applying a tint to a DisplayObject whereas HexColorsPlugin is for animating any color property of any object. The tint has to be applied in a very specific way to a MovieClip/Sprite, for example, because there is no "tint" property. The plugin does that work for you. But sometimes you might have some other object that has a color property that you want to tween and that's what HexColorsPlugin is for.

 

var obj:Object = {myColor:0xFF0000};
TweenLite.to(obj, 2, {hexColors:{myColor:0x0000FF}, onUpdate:showColor});
function showColor():void {
   trace("obj.myColor is " + obj.myColor); 
}

 

Does that clear things up?

 

 

There is absolutely no difference in terms of hte

  • Like 1
Link to comment
Share on other sites

Okay, so basically TintPlugin is HexColors + More (whatever is needed for tinting), correct?

 

So I'm not missing out on anything if I use TintPlugin?

 

Thanks for the quick replies, Jack.

Link to comment
Share on other sites

I suppose you could think about it that way (although it's not quite that simple). If all you need to do is animate a MovieClip/Sprite/DisplayObject to a particular color, TintPlugin is indeed all you need. Yep.

  • Like 1
Link to comment
Share on other sites

Okay, although regarding the "its not so simple" part, I've opened up Tint and HexColors and Tint doesn't seem to have the code that hex colors has. Unless ColorTransform takes care of that. It seems to be linearly tweening the color using updateTweens().

 

Although I trust what you say, from a code perspective I still don't see how they are similar. HexColors seems to tween each prop (RGB) seperately, but Tint seems to do it together. Am I missing something?

 

I don't mind complicated explanations, if you have the time. Thanks again, Jack.

Link to comment
Share on other sites

Yep, ColorTransform is just a layer of abstraction that does the same sort of thing but is necessary for applying tints to DisplayObjects in AS3. HexColorsPlugin is more of a raw tool that handles busting the red, blue, and green components of a hex color apart and tweening them separately and then re-combining them to form a hex color again before applying it.

 

Under the hood they're doing exactly the same thing. Think of ColorTransform's redOffset, blueOffset, and greenOffset as being the red, blue, and green components of a hex color. The TintPlugin is tweening the ColorTransform instance's redOffset, blueOffset, and greenOffset whereas HexColorsPlugin is creating its own generic object with red, blue and green properties and tweening those.

 

Make sense?

  • Like 1
Link to comment
Share on other sites

Beautiful. Absolutely fantastic. Never thought of it that way.

 

Thanks a ton, jack! You really are a support superhero. No kidding.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×