The Way To Great

通往伟大的路

z wID:zinking3
49200次访问,排名2049(-1)好友13人,关注者18
where there is a will,there is a way to great.
zinking3的文章
原创 190 篇
翻译 6 篇
转载 14 篇
评论 22 篇
Albert的公告
最近评论
强悍的沉默:辛苦了
songhuanren:不错.,很有价值,但as3的项目好像就不行了吧.
assicen:自我认为 在目前看来C/C++并非程序员必须掌握的语言 领域不同 应用不同 当然语言也不会相同
寒雨:说的不错,要想在更深入的发展,必须把基础学好,c/c++是最基础的,哥们有同感!!!知己呀··
Johnshen007:看上去相当不错,支持!
文章分类
收藏
相册
RIA的朋友们
不会飞的鱼
更新很快,关注业内的RIA朋友Y-Boy(RSS)
存档
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
订阅到BlogLines
订阅到Yahoo
订阅到GouGou
订阅到飞鸽
订阅到Rojo
订阅到newsgator
订阅到netvibes

原创 使用图形滤镜来扩展基本的组件收藏

新一篇: Flex编译器支持条件编译 | 旧一篇: 【NT.CC】61套免费的商业WORDPRESS模板

使用图形滤镜来扩展基本的组件

| | Comments (0)

 
folders.jpg

在前面的帖子中我曾经讲到过如何使用图形滤镜,这篇博文中我将介绍如何使用这些滤镜来增强基本组件的能力,在本示例中我将展示如何使用滤镜来改变基本的TREE组件的外观
我曾经无数次的碰到过这个问题,那就是如何通过TREE图标来表示其当前的TREE展开状态

我总是在寻找将数据可视化的方法,这里有一个非常简单的方来来扩展一个基本的TREE组件的图标所蕴含的意味,我见过无数种的实现方式,但是我认为下面的是其中最简单的一种方法,它使用了ColorMatrixFilter 来改变TREE文件夹的颜色,你可以使用这项技巧将一些文件夹分组到一起,采用特定的颜色来表示树的不同层次,根据文件夹或者是数据来改变树图标的现实状态,当然还有更多

下面就是:


下面我就展示它是如何实现的,它使用了一个定制的ITEM RENDER,该render扩展了TREEITEMRENDER类,在commitProperties 方法中,应用了ColorMatrixFilter 过滤当前文件夹的图标,就是这么简单,而没有什么更换图标或者是替代之类的。


override protected function commitProperties():void
{
     super.commitProperties();
     
     
if ( icon )
     
{
          var matrix:Array 
= new Array();
          
          
switch (TreeListData( listData ).depth )
          
{
               
case 1:
                   matrix 
= matrix.concat([10000]); // red
                   matrix = matrix.concat([0, .25000]); // green
                   matrix = matrix.concat([00, .2500]); // blue
                   matrix = matrix.concat([00010]);     // alpha
                   icon.filters = [ new ColorMatrixFilter( matrix) ]
                   
break;
               
case 2:
                   matrix 
= matrix.concat([.250000]); // red
                   matrix = matrix.concat([01000]); // green
                   matrix = matrix.concat([00, .2500]); // blue
                   matrix = matrix.concat([00010]);     // alpha
                   icon.filters = [ new ColorMatrixFilter( matrix) ]
                   
break;
               
case 3:
                   matrix 
= matrix.concat([.250000]); // red
                   matrix = matrix.concat([0, .25000]); // green
                   matrix = matrix.concat([00100]); // blue
                   matrix = matrix.concat([00010]);     // alpha
                   icon.filters = [ new ColorMatrixFilter( matrix) ]
                   
break;
               
default:
                   icon.filters 
= [];
                   
break;
           }

      }

}




当然这些代码在定制的TREE图标上也可以工作
源代码链接:
http://www.tricedesigns.com/portfolio/colorfolders/srcview/index.html

http://www.tricedesigns.com/portfolio/colorfolders/srcview/TreeColors.zip.html

Note: There are 2 separate files in there "TreeColors.mxml" and "CustomFolderTreeColors". The only difference between these two are the specification of custom folder icons.



Using Graphics Filters to Extend Basic Components

| | Comments (0)
AddThis Social Bookmark Button
 
folders.jpg
I've discussed graphics filters previously, and here's a trick to use them to extend the capabilities of basic Flex controls. In this example, graphics filters will be used to alter the appearance of a basic tree control. I've run into this scenario numerous times... How can you change the appearance of tree folder icons to imply meaning to the branches of the tree?

I'm always looking for ways to visualize data, and this is a very easy way to extend a basic tree control to add meaning to it. I've seen different implementations, but I think this is the easiest so far. This technique uses a ColorMatrixFilter to change the colors of the tree folders. You could use this technique to visually group specific folders together, show specific tree levels in specific colors, change color depending upon folder contents or data, etc... There are a lot of applications for this.

Here it is:



Now, here's how it works. It uses a custom item renderer that extends the TreeItemRenderer class. Within the commitProperties method, a ColorMatrixFilter is applied to the existing folder icon (the "icon" property). It's that simple... There is no custom drawing or image substitution necessary.

override protected function commitProperties():void
{
super.commitProperties();

if ( icon )
{
var matrix:Array = new Array();

switch (TreeListData( listData ).depth )
{
case 1:
matrix = matrix.concat([1, 0, 0, 0, 0]); // red
matrix = matrix.concat([0, .25, 0, 0, 0]); // green
matrix = matrix.concat([0, 0, .25, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha
icon.filters = [ new ColorMatrixFilter( matrix) ]
break;
case 2:
matrix = matrix.concat([.25, 0, 0, 0, 0]); // red
matrix = matrix.concat([0, 1, 0, 0, 0]); // green
matrix = matrix.concat([0, 0, .25, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha
icon.filters = [ new ColorMatrixFilter( matrix) ]
break;
case 3:
matrix = matrix.concat([.25, 0, 0, 0, 0]); // red
matrix = matrix.concat([0, .25, 0, 0, 0]); // green
matrix = matrix.concat([0, 0, 1, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha
icon.filters = [ new ColorMatrixFilter( matrix) ]
break;
default:
icon.filters = [];
break;
}
}
}

This will also work on top of custom folder icons, as you can see here:


You can view the full source code here:
http://www.tricedesigns.com/portfolio/colorfolders/srcview/index.html

You can download the application source code here:
http://www.tricedesigns.com/portfolio/colorfolders/srcview/TreeColors.zip.html

Note: There are 2 separate files in there "TreeColors.mxml" and "CustomFolderTreeColors". The only difference between these two are the specification of custom folder icons.

发表于 @ 2008年04月28日 14:35:57|评论(loading...)|编辑

新一篇: Flex编译器支持条件编译 | 旧一篇: 【NT.CC】61套免费的商业WORDPRESS模板

评论:没有评论。

发表评论  


登录
Csdn Blog version 3.1a
Copyright © Albert