CS4 Only: Using AdjustColor()

March 9, 2009 by jared 

Get Adobe Flash player

Flash 10 only: the AdjustColor class allows you to modify brightness, hue, saturation, and contrast without using a ColorMatrix.

Click here to download the sample files.

Comments

3 Responses to “CS4 Only: Using AdjustColor()”

  1. Dave Bleeker on November 14th, 2009 6:27 am

    You can also easy tween this filter by using the CalculateFinalFlatArray() method of the AdjustColor. I made a simple example here for those who are interested:

    package
    {
    import flash.display.*;
    import fl.motion.AdjustColor;
    import flash.filters.ColorMatrixFilter;
    import fl.transitions.*;
    import fl.transitions.easing.*;

    public class myClass extends Sprite
    {
    private var mySprite:Sprite;

    public function myClass()
    {
    var mySprite:Sprite = new Sprite();
    mySprite.graphics.beginFill(0xFFFF00);
    mySprite.graphics.drawRect(0, 0, 150, 100);
    mySprite.graphics.endFill();
    addChild(mySprite);

    var adjColor:AdjustColor = new AdjustColor();
    adjColor.saturation = 0;
    adjColor.contrast = 0;
    adjColor.brightness = 0;
    adjColor.hue = 0;

    colorTween = new Tween(adjColor, “hue”, None.easeIn, 0, 125, 2, true);

    colorTween.addEventListener(TweenEvent.MOTION_CHANGE, updateColors);
    }

    private function updateColors(e:TweenEvent):void
    {
    var cmf:ColorMatrixFilter = new ColorMatrixFilter(adjColor.CalculateFinalFlatArray());
    mySprite.filters = [cmf];
    }
    }
    }

    I hope it’s useful for someone

  2. Dave Bleeker on November 14th, 2009 6:32 am

    ooops.. little correction.. just declare the AdjustColor under the sprite so it will be known in the function updateColors:

    private var mySprite:Sprite;
    private var adjColor:AdjustColor;

    and in the function myClass:

    mySprite = new Sprite(); // No need to redeclare
    adjColor = new AdjustColor();

    Sorry for the mistake, I just wrote the whole thing in this textarea here, I guess my brain was locked in scramble mode :-p

  3. Jared on November 30th, 2009 7:56 pm

    Thanks dave that is awesome.

Feel free to leave a comment...
and oh, if you want a pic to show with your comment, go get a gravatar!