Quick tip: Contrast & Brightness In ActionScript 3

There are multiple libraries that lets you adjust contrast, brightness, hue, saturation. Lets have look at some:

fl.motion.AdjustColor class is a part of Flash CS4:

import flash.filters.ColorMatrixFilter;
import fl.motion.AdjustColor;
// AdjustColor class location:
// Adobe Flash CS4/Common/Configuration/ActionScript 3.0/projects/Flash/src/fl/motion/AdjustColor.as

var color:AdjustColor = new AdjustColor();
color.brightness = brightness;
color.contrast = contrast;
color.hue = 0;  
color. saturation = 0;
image.filters = [new ColorMatrixFilter(color.CalculateFinalFlatArray())];

caurina.transitions.ColorMatrix class created by Jens Krause

import caurina.transitions.ColorMatrix;
import flash.filters.ColorMatrixFilter;

var matrix:ColorMatrix = new ColorMatrix();
image.filters = [new ColorMatrixFilter(matrix.matrix)];

com.gskinner.geom.ColorMatrix created by gSkinner

import com.gskinner.geom.ColorMatrix;
import flash.filters.ColorMatrixFilter;

var matrix:ColorMatrix = new ColorMatrix();
matrix.adjustColor(brightness, contrast, saturation, hue);
image.filters = [new ColorMatrixFilter(matrix)];

Where to go from here:

1 comment so far

  1. Samana August 26, 2010 10:43

    Thank you!!!

Leave a comment

Please be polite and on topic. Your e-mail will never be published.