ColorMatrixFilter tweening offers an easy way to tween a DisplayObject's saturation, hue, contrast,
brightness, and colorization. The following properties are available (you only need to define the ones you want to tween):
colorize : uint
(colorizing a DisplayObject makes it look as though you're seeing it through a colored piece of glass whereas tinting it makes every pixel exactly that color. You can control the amount of colorization using the "amount" value where 1 is full strength, 0.5 is half-strength, and 0 has no colorization effect.)
amount : Number [1]
(only used in conjunction with "colorize")
contrast : Number
(1 is normal contrast, 0 has no contrast, and 2 is double the normal contrast, etc.)
saturation : Number
(1 is normal saturation, 0 makes the DisplayObject look black and white, and 2 would be double the normal saturation)
hue : Number
(changes the hue of every pixel. Think of it as degrees, so 180 would be rotating the hue to be exactly opposite as normal, 360 would be the same as 0, etc.)
brightness : Number
(1 is normal brightness, 0 is much darker than normal, and 2 is twice the normal brightness, etc.)
threshold : Number
(number from 0 to 255 that controls the threshold of where the pixels turn white or black)
matrix : Array
(If you already have a matrix from a ColorMatrixFilter that you want to tween to, pass it in with the "matrix" property. This makes it possible to match effects created in the Flash IDE.)
index : Number
(only necessary if you already have a filter applied and you want to target it with the tween.)
addFilter : Boolean [false]
remove : Boolean [false]
(Set remove to true if you want the filter to be removed when the tween completes.)
HINT: If you'd like to match the ColorMatrixFilter values you created in the Flash IDE on a particular object, you can get its matrix like this:
import flash.display.DisplayObject;
import flash.filters.ColorMatrixFilter;
function getColorMatrix(mc:DisplayObject):Array {
var f:Array = mc.filters, i:uint;
for (i = 0; i < f.length; i++) {
if (f[i] is ColorMatrixFilter) {
return f[i].matrix;
}
}
return null;
}
var myOriginalMatrix:Array = getColorMatrix(my_mc); //store it so you can tween back to it anytime like TweenMax.to(my_mc, 1, {colorMatrixFilter:{matrix:myOriginalMatrix}});
USAGE:
import com.greensock.TweenLite;
import com.greensock.plugins.TweenPlugin;
import com.greensock.plugins.ColorMatrixFilterPlugin;
TweenPlugin.activate([ColorMatrixFilterPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.
TweenLite.to(mc, 1, {colorMatrixFilter:{colorize:0xFF0000}});
Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in
http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.