Jump to content
Search Community

TintPlugin vs HexColorsPlugin

Jeremy Rudd test
Moderator Tag

Recommended Posts

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, 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

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.
×
×
  • Create New...