topical media & game development

talk show tell print

#graphic-flex-image-effects-02-Flex-ColorMatrixFilterTest.ax

#graphic-flex-image-effects-02-Flex-ColorMatrixFilterTest.ax [swf] [flash] flex


  package {
  
          import flash.filters.ColorMatrixFilter;
  
          [SWF(width=550, height=400, backgroundColor=0xEEEEEE)]
  
          
Tests application of the ColorMatrixFilter to an image in order to tint it.

  
          public class @ax-graphic-flex-image-effects-02-Flex-ColorMatrixFilterTest extends graphic_flex_image_effects_02_Flex_ImageFilterTest {
  
                  
Applies bitmap filter to image.

  
                  override protected function applyFilter():void {
                          // purple tint to apply
                          var tint:uint = 0xFF00CC;
                          // amount to apply
                          var percent:Number = .5;
                          var r:uint = tint >> 16 & 0xFF;
                          var g:uint = tint >> 8 & 0xFF;
                          var b:uint = tint & 0xFF;
                          var matrix:Array = [
                                  r/255, 0.59, 0.11, 0, 0,
                                  g/255, 0.59, 0.11, 0, 0,
                                  b/255, 0.59, 0.11, 0, 0,
                                  0,     0,    0,    1, 0
                          ];
                          var filter:ColorMatrixFilter = new ColorMatrixFilter(matrix);
                          _bitmap.filters = [filter];
                  }
  
          }
  
  }
  


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.