Apr 04

Extending TreeItemRenderer to replace default icons with icons unique to each branch/leaf



[The following was created as of Flex 2, Beta 2]



Here’a a simple example of how to extend TreeItemRenderer to modify the tree items. In this example we apply a different style for branch nodes and leaf nodes. We also remove the default icons and place an image in it’s place.



For my purposes, I want to have a different image in each tree item at runtime, and this is the solution I came up with. This example just places a ‘branch’ image for branches, and a ‘leaf’ image for leaf items, but it can be easily modified to do what I just described.









CustomTreeItemRenderer.mxml



View the source here



Many thanks to Joan Tan for getting me started on this!

Post to Twitter

Mar 16

[The following was created as of Flex 2, Beta 2]



It’s not uncommon to want to bind a class to one of the List based components (i.e. List, TileList, DataGrid, etc).
But if you’re using an itemRenderer you may run into an issue where the itemRenderers do not get unique id’s.
When this happens, focus and selection cannot function properly. Usually, just one of the items in the list will get highlighted no matter which item your cursor is over.



So the way to get around this, is to simply have your class implement IUID which will automatically assign a unique id to each item renderer.



Here’s a sample:



View the source here

Post to Twitter

 
preload preload preload