Packagecom.greensock.plugins
Classpublic class HexColorsPlugin
InheritanceHexColorsPlugin Inheritance TweenPlugin Inheritance Object

[AS3/AS2 only] Although hex colors are technically numbers, if you try to tween them conventionally, you'll notice that they don't tween smoothly. To tween them properly, the red, green, and blue components must be extracted and tweened independently. The HexColorsPlugin makes it easy. To tween a property of your object that's a hex color to another hex color, just pass a hexColors Object with properties named the same as your object's hex color properties. For example, if myObject has a "myHexColor" property that you'd like to tween to red (0xFF0000) over the course of 2 seconds, you'd do:

TweenMax.to(myObject, 2, {hexColors:{myHexColor:0xFF0000}});

You can pass in any number of properties.

USAGE:

import com.greensock.TweenLite; 
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.HexColorsPlugin;
TweenPlugin.activate([HexColorsPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.
TweenLite.to(myObject, 2, {hexColors:{myProperty:0xFF0000}});

Or if you just want to tween a color and apply it somewhere on every frame, you could do:

var myColor:Object = {hex:0xFF0000};
TweenLite.to(myColor, 2, {hexColors:{hex:0x0000FF}, onUpdate:applyColor});
function applyColor() {
    mc.graphics.clear();
    mc.graphics.beginFill(myColor.hex, 1);
    mc.graphics.drawRect(0, 0, 100, 100);
    mc.graphics.endFill();
}

Copyright 2008-2013, GreenSock. All rights reserved. This work is subject to the terms in http://www.greensock.com/terms_of_use.html or for Club GreenSock members, the software agreement that was issued with the membership.



Public Methods
 MethodDefined By
 Inherited
activate(plugins:Array):Boolean
[static] Activates one or more plugins so that TweenLite and TweenMax recognize the associated special properties.
TweenPlugin