flex特效(3):扩展基本控件实现一个自定义图标的导航树

来源:百度文库 编辑:神马文学网 时间:2024/04/26 22:42:10

flex特效(3):扩展基本控件实现一个自定义图标的导航树

时间:2010-08-06 13:02来源:未知 作者:admin 点击:53次flex特效收集与汇总(3):扩展基本控件实现一个自定义图标的导航树

扩展了TreeItemRenderer类。在commitProperties方法,ColorMatrixFilter应用到现有的文件夹图标(“图标”属性)。

关键代码

  1. override protected function commitProperties():void  
  2. {  
  3.     super.commitProperties();  
  4.       
  5.     if ( icon )  
  6.     {  
  7.         var matrix:Array = new Array();  
  8.           
  9.         switch (TreeListData( listData ).depth )  
  10.         {  
  11.             case 1:  
  12.                 matrixmatrix = matrix.concat([1, 0, 0, 0, 0]); // red  
  13.                 matrixmatrix = matrix.concat([0, .25, 0, 0, 0]); // green  
  14.                 matrixmatrix = matrix.concat([0, 0, .25, 0, 0]); // blue  
  15.                 matrixmatrix = matrix.concat([0, 0, 0, 1, 0]);    // alpha  
  16.                 icon.filters = [ new ColorMatrixFilter( matrix) ]  
  17.                 break;  
  18.             case 2:  
  19.                 matrixmatrix = matrix.concat([.25, 0, 0, 0, 0]); // red  
  20.                 matrixmatrix = matrix.concat([0, 1, 0, 0, 0]); // green  
  21.                 matrixmatrix = matrix.concat([0, 0, .25, 0, 0]); // blue  
  22.                 matrixmatrix = matrix.concat([0, 0, 0, 1, 0]);    // alpha  
  23.                 icon.filters = [ new ColorMatrixFilter( matrix) ]  
  24.                 break;  
  25.             case 3:  
  26.                 matrixmatrix = matrix.concat([.25, 0, 0, 0, 0]); // red  
  27.                 matrixmatrix = matrix.concat([0, .25, 0, 0, 0]); // green  
  28.                 matrixmatrix = matrix.concat([0, 0, 1, 0, 0]); // blue  
  29.                 matrixmatrix = matrix.concat([0, 0, 0, 1, 0]);    // alpha  
  30.                 icon.filters = [ new ColorMatrixFilter( matrix) ]  
  31.                 break;  
  32.             default:  
  33.                 icon.filters = [];  
  34.                 break;  
  35.         }  
  36.     }  

 效果演示:

 

  

完整代码请到:http://www.tricedesigns.com/portfolio/colorfolders/srcview/index.html 下载。