Re: [flexcoders] Customizing TreeItemRenderer

2008-07-10 Thread Troy Gilbert
So, is TreeItemRenderer really that much of a black art? Has no one
done any interesting modifications of that component? Maybe a good
indicator that it's a hard to customize component?

Maybe this would be a good opportunity for a solid Adobe tut on the subject...

Troy.


RE: [flexcoders] Customizing TreeItemRenderer

2008-07-10 Thread Tracy Spratt
I have an example on www.cflex.net http://www.cflex.net/  that is
pretty good, not too complex, not braindead simple, that uses good
practice and shows overriding commitProperties and updateDisplayList.
It draws lines between sibling nodes. Wish I could claim it all as my
work.

 

http://www.cflex.net/showfiledetails.cfm?ChannelID=1Object=FileobjectI
D=575

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Troy Gilbert
Sent: Thursday, July 10, 2008 5:30 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Customizing TreeItemRenderer

 

So, is TreeItemRenderer really that much of a black art? Has no one
done any interesting modifications of that component? Maybe a good
indicator that it's a hard to customize component?

Maybe this would be a good opportunity for a solid Adobe tut on the
subject...

Troy.

 



[flexcoders] Customizing TreeItemRenderer

2008-07-09 Thread thirtyfivemph
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.