Posted By

fxkill on 01/19/11


Tagged

flash color as3 Brightness saturation contrast hue colormatrixfilter AdjustColor adjust


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

kure69
ptiswitz


AdjustColor Hue Saturation Brightness Contrast of a MovieClip


 / Published in: ActionScript 3
 

This snippet is for when you need to adjust the colours of a display object on the fly using code. It's the equivalent of using the "Adjust Color" filter on a MovieClip.

  1. import fl.motion.AdjustColor;
  2. import flash.filters.ColorMatrixFilter;
  3.  
  4. var colorFilter:AdjustColor = new AdjustColor();
  5. var mColorMatrix:ColorMatrixFilter;
  6. var mMatrix:Array = [];
  7. var MC:MovieClip = new MovieClip();
  8.  
  9. function adjustColors():void
  10. {
  11. //all 4 must contain a value of an integer, if one is not set, it will not work
  12. colorFilter.hue = 50;
  13. colorFilter.saturation = 50;
  14. colorFilter.brightness = 50;
  15. colorFilter.contrast = 0;
  16.  
  17. mMatrix = colorFilter.CalculateFinalFlatArray();
  18. mColorMatrix = new ColorMatrixFilter(mMatrix);
  19.  
  20. MC.filters = [mColorMatrix];
  21. }

Report this snippet  

You need to login to post a comment.