ThisCodeYes as2
You can use a matrix to conveniently operate colors in flash.
Colormatrixfilter is very powerful. Its package is: Import flash. Filters. colormatrixfilter;
The values of red, green, and blue channels are determined by the calculation method shown below:
Code:
Redresult = A [0] * srcr + A [1] * srcg + A [2] * SRCB + A [3] * srca + A [4]
Greenresult = A [5] * srcr + A [6] * srcg + A [7] * SRCB + A [8] * srca
+ A [9]
Blueresult = A [10] * srcr + A [11] * srcg + A [12] * SRCB + A [13] *
Srca + A [14]
Alpharesult = A [15] * srcr + A [16] * srcg + A [17] * SRCB + A [18] *
Srca + A [19]
We can see that the value of the first line determines the red value, the second line determines the green, the third line blue, and the fourth line is the transparent (alpha) channel value. We can also see that the first four columns are consistent with red, green, blue, and Alpha.
The product of the channel value, and the value in the fifth column is the sum (offset ). Note that the source and result values of each row are in the range from 0 to 255. Therefore, even if the value of each channel is less than 0 or greater than 255, it will be forced
Within the interval.
1. Black and white. Spr. Filters = [New colormatrixfilter (
[1, 0, 0, 0, 0,
1, 0, 0, 0,
1, 0, 0, 0,
0, 0, 0, 0
])]; 2. It is highlighted. Spr. Filters = [New colormatrixfilter (
[1, 0, 0, 50,
0, 1, 0, 0, 50,
0, 0, 1, 0, 50,
0, 0, 0, 0
])];