Home > Development > blogs
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.
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.
___________________________________
Andrew Trice
Principal Architect
Cynergy Systems
http://www.cynergysystems.com
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.
___________________________________
Andrew Trice
Principal Architect
Cynergy Systems
http://www.cynergysystems.com
- comments: 0
Stay Connected
 InsideRIA Atom Feed
InsideRIA Development Atom Feed
InsideRIA Newsletter
↑ Put InsideRIA News on Your Site
Search InsideRIA
News & Events
Latest Features
Tag Cloud
- .net
- 3d
- actionscript
- adam flater
- adobe
- air
- air api
- air cookbook
- air resources
- air xml webkit
- ajax
- ajaxworld
- alertthingy
- amp
- analytics
- ant
- antipattern
- api
- appengine
- apple
- april fools day
- aptana
- architecture
- asp
- away3d
- aws
- bad usability calendar
- benchmarking
- berlin
- beta
- bitmaps
- blazeds
- blendmode
- book
- browserplus
- cairngorm
- camp
- career
- chart
- cloud
- code
- code generation
- coldfusion
- command design pattern
- communication
- community
- compiler
- component
- compression
- conference
- cs4
- curl
- customer
- cuzillion
- dare
- data
- datavisualization
- dbunit
- ddlutils
- debug
- decompiler
- deep zoom
- degrafa
- design
- design patterns
- desktop
- development
- diary
- dionalmaer
- drawing api
- dreamweaver
- drupal
- ejb 3.0
- elixir
- embedded jboss
- encryption
- europe
- event
- excerpt
- experience
- ext
- externalinterface
- eyetracking
- features
- filters
- fireworks
- fitc
- flash
- flash10
- flashforward
- flashplayer
- flex
- Flex
- flexbuilder
- flexunit
- form factor
- framework
- friendfeed
- gadget
- gears
- gesture
- googledocs
- googlegears
- graphics
- graphics mask
- guimark
- hosting
- how-to
- html
- ia
- ie
- ie8
- igoogle
- interaction
- interface
- interview
- iphone
- iphonedevcamp
- j2ee
- jakob
- java
- javafx
- javaone
- javascript
- javase
- javase6
- jaxer
- jms
- job
- joyent
- keynote
- languages
- lcds
- learning
- lffs
- library
- licensing
- linux
- listen
- livecycle data services
- madrid
- map
- marketing
- math
- maturity
- maven
- memory
- merapi
- mesh
- metrics
- microsoft
- mikepotter
- mix08
- mobile
- model locator design pattern
- mono
- mozilla
- mvc
- mxmlc
- neilson
- nio
- nitro
- nitrolm
- offline
- onairbustour
- onairtour
- onairtoureurope
- ontologies
- oop
- open source
- OpenFlux
- openscreen
- opensource
- orm
- papervision3d
- paris
- pattern
- pattern mining
- performance
- php
- podcast
- portable
- preload
- pricing
- prism
- Processing
- profiler
- protagonize
- push
- rails
- release
- research
- resources
- ria
- ria community
- rich
- ruby
- sanctuary
- scheduling
- scott sheridan
- search
- security
- seo
- server
- service oriented architecture
- services
- session bean
- silverlight
- singularity
- social
- source
- spain
- spry
- sqlite
- static code
- steveounders
- stockholm
- streaming
- survey
- swc
- swf
- switchboard
- syscon
- test driven development
- testing
- testng
- thermo
- tip
- tools
- trends
- tufte
- tutorial
- ui
- ui pattern library design
- uirc
- unconference
- unit testing
- usability
- user experience
- ux
- vector images
- view source
- vision
- warsaw
- wdn08
- web
- web 2.0
- web 2.0 expo
- whenisgood
- why
- widgets
- workshop
- wwdc
- xulrunner
- yahoo
- yui
Related Books
Development Series
Get an overview of the tools and technologies that work together to allow developers to build Rich Internet Applications (RIAs) quickly and easily.
Recent Comments
Archives
About This Site
Welcome to the premiere community site for all things RIA sponsored by O'Reilly Media and Adobe Systems Incorporated.
About Us
Meet the Experts
Meet Our Contributors
Send Us Feedback


Comments
Leave a comment