Please note that ExpatTech no longer operates regular office hours, meeting is by appointment only. Please call +36306031104 for details.

ExpatTech Techblog

Peter Todd 2009.12.02. 14:40

Flash Cookbook - Colors - brightness of movieclip

Now we learn how to set the brightness of a movieclip. It's quite easy and it will be our first step into colormatrixfilter.

function setBrightness(target:MovieClip, value:Number = 0):void
{
    var element:Number = value;
    var matrix:Array = [1, 0, 0, 0, element,
            0, 1, 0, 0, element,
            0, 0, 1, 0, element,
            0, 0, 0, 1, 0];
    var colorfilter:ColorMatrixFilter = new ColorMatrixFilter(matrix);

    target.filters = [colorfilter];
}

The colormatrix filter is constructed with a matrix. The value for brightness can go from -255 to 255.