I want to display a custom widget (basically a glorified Image control) in place of the icons in a Tree component. I've not been able to get satisfactory results (yet), here's what I've done:
1) First, I tried creating a custom ItemRenderer, but discovered that the disclosure icon (triangle), indenting, etc., are all features of the item renderer, not the tree itself (which I found weird), and that's more than I wanted to implement myself. BTW, if I just stick any old item renderer into a tree, it seems like it starts working almost identically to a standard List... seems like I'm missing something... shouldn't the "tree" parts be handled by the Tree component and not it's item renderer? 2) So, I created a custom item renderer that inherited from TreeItemRender. Taking after some examples I've seen online, I overrided updateDisplayList() to hide the icon and position my own widget in its place. This works okay, with several problems: a) I've got to do a lot of custom layout if my widget is a different size than the icon (or sub in an icon of equivalent size). b) I get weird rendering artifacts where when the tree is refreshed (like if you open a branch) all of the item renderers beneath the opened branch flash their disclosure icons (whether they had them or not) and my custom widget jumps to position 0,0, for single frame then everything corrects itself. 3) So, I got clever and looked through how TreeItemRenderer handles it's icon. I found that the icon is created/destroyed in one spot, commitProperties, which is the only place that has the "knowledge" that it's based on a Class instead of being any old DisplayObject. So, I overrided commitProperties() and replaced the icon instance with an instance of my widget (a UIComponent). For some reason, this doesn't work! The tree doesn't seem to compensate for the icon's larger size, etc., even though calculations are done inside of updateDisplayList()! Any clues? Any ideas? Troy.