Jump to content
Search Community

tweening ColorMatrixFilter

accessdev test
Moderator Tag

Recommended Posts

Hello,

 

 

I have a ColorMatrixfilter on somes MCs.

 

the transformation looks like that ( sort of greyscale filter)

 


matrix = new Array();
matrix=matrix.concat([0.4,0.333,0.333,0,0]);// red
matrix=matrix.concat([0.333,0.4,0.333,0,0]);// green
matrix=matrix.concat([0.333,0.333,0.4,0,0]);// blue
matrix=matrix.concat([0,0,0,1,0]);// alpha

my_filter = new ColorMatrixFilter(matrix);

my_mc.filters = new Array(my_filter);


 

 

What is the simple way to update this filter to move to "normal" state with 1,1,1 respectively in R,G,B channels ?

Link to comment
Share on other sites

The easy way to do a gray scale effect would be to use the TweenLite colorMatrixFilter and simply tween to a saturation value of 0

 

import com.greensock.*; 
import com.greensock.easing.*;
import com.greensock.plugins.*;

TweenPlugin.activate([EndArrayPlugin, ColorMatrixFilterPlugin]);


TweenMax.to(mc, 1, {colorMatrixFilter:{saturation:0}});

 

 

The beauty of this plugin is that it completely hides the complexity of tweening multiple arrays of channel data and repeatedly updating and applying filter settings on your display objects.

 

please see the plugin explorer at http://www.tweenmax.com for an interactive example.

 

 

if you insist on manually tweening each channel's array of values yourself, take a look at the endArray plugin that will allow you to tween any array of values to your desired end array of values.

There is also an example in this in the plugin explorer. *note you will have to create your own onUpdate function that repeatedly creates a new matrix, applies it to your filter, and then applies that filter to your mc.

 

I would definitely opt for spending a few minutes fiddling with the settings in the plugin explorer / colorMatrixFilter or colorTransform and using the generated code.

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