|
||||||
|
||||||
Color Matrix Filter with ActionScript

Free
Flash Tutorial
Step Two: The ActionScript
Note: With Script Assist on you cannot type in the Actions Panel. If you want to learn more about Script Assist see the tutorial on the Actions Panel
// Makes the filter available to use in the Movie.
import flash.filters.ColorMatrixFilter;// Defines which colors to change.
var myMatrix:Array = [2,0,0,0,0, /* Red */
0,1,0,0,0, /* Green */
0,0,2,0,0, /* Blue */
0,0,0,1,0 ]; /* Alpha Transparency */// Creates a variable with info about the Filter settings.
var colorMatrix = new ColorMatrixFilter(myMatrix);// Applies the filter to the object named myObject.
myObject.filters = [colorMatrix];
Note: If you wish you can type the Matrix in a more standard format like this:
[2,0,0,0,0,0,1,0,0,0,0,0,2,0,0,0,0,0,1,0];
Or like this:
[2,0,0,0,0, 0,1,0,0,0, 0,0,2,0,0, 0,0,0,1,0];
I have spread it out into a matrix as this makes it is much easier to understand and edit. If you wish to type the code in a matrix format make sure you don't get your commas (,) and semi colons (;) mixed up. If you do you will get errors. There is only one semi colons (;) which defines the codes end of line:
[2,0,0,0,0, /* Red */
0,1,0,0,0, /* Green */
0,0,2,0,0, /* Blue */
0,0,0,1,0]; /* Alpha Transparency */If you wish you can leave out the gray comments and white space. I only add the comments and space to make the code easier to read and edit. It could just as well be typed like this:
[2,0,0,0,0,
0,1,0,0,0,
0,0,2,0,0,
0,0,0,1,0];
I hope you have found this useful. If so perhaps you could recommend this site to others and link to webwasp!
|
Why not try out webwasp's new community. Meet new people, find friends in your area: Webwasp Mates & Dates
•
16547 visitors to this page since
2 April 07 •
|
|
|

Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend:
Click here
All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.
|