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

ExpatTech Techblog

Peter Todd 2010.10.01. 09:01

Flash Cookbook - Colors - Part 2. Invert Displayobject's Colors

To invert the colors of a displayobject you can use the transform.colorTransform property of the displayobject and apply a ColorTransform to it.

The ColorTransform object you will use in this battle is:

var colortransform:ColorTransform = new ColorTransform(-1, -1, -1, 1, 255, 255, 255, 0);

To put it in a handy little function:

static public function invert(object:DisplayObject = null):ColorTransform
{
    if(object != null) object.transform.colorTransform = new ColorTransform(-1, -1, -1, 1, 255, 255, 255, 0);
    
    return new ColorTransform(-1, -1, -1, 1, 255, 255, 255, 0);
}