Recipe 10.10. Making a Digital Negative


Problem

You want to make a digital negative from a display object.

Solution

Use a digital negative matrix and apply it with a ColorMatrixFilter object.

Discussion

You can use a digital negative matrix in conjunction with a flash.filters.ColorMatrixFilter object to apply the matrix. The digital negative matrix is as follows:

-1  0  0  0  255  0 -1  0  0  255  0  0 -1  0  255  0  0  0  1  0

The following example applies a digital negative effect to a display object:

sampleSprite.filters = [new ColorMatrixFilter([-1, 0, 0, 0, 255, 0, -1, 0, 0, 255, 0, 0, -1, 0, 255, 0, 0, 0, 1, 0])];

You can also use the ascb.filters.ColorMatrixArrays.DIGITAL_NEGATIVE constant, as shown here:

sampleSprite.filters = [new ColorMatrixFilter(ColorMatrixArrays.DIGITAL_NEGATIVE)];




ActionScript 3. 0 Cookbook
ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers
ISBN: 0596526954
EAN: 2147483647
Year: 2007
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net