UPDATED TreeItemRenderer in flex
I got a question from Randall in the comments of my site the other day and thought I should post the answer to his question:
"My questions is if you know how to control the display location of the icon and/or label? These seem to be displayed by the super.updateDisplayList function, and therefore display where they want to, regardless of what other visual objects are in the item (cell). Is it possible to layout boxes, and put the icon and label into one of them? If so, can you give us a quick example of this? "
Well yes its possible as the image below shows. I put an Hbox in then made the label and button children of it. they can now be controlled via css. Its a quick example but can be taken further quite quicky.
If you were to take it further you would have to extend the measuring methods in the class to update the hieght width etc so the items were placed in the right errrrrrr place.
Anyway heres your sample Randall. Its included with the old source so you can chop and change the renderers. Let me know what you think.
Also as always use the mx framework source as your guide…thats why its there (props to Adobe for that). Also go check out some of the sweet components that Mike is doing over at http://www.teotigraphix.com/flex2/.

Hi,
See, when you get to know me, I am like one of those engineers that points out things that might not make a difference right now but would mean your building stays up in an earthquake.
My comment is that if you plan to make anything that will either be reused OR misson critical, do not use Containers in itemRenderers.
The reason being is it’s like adding 10 transmissions to one car, you can do it but performance loss will always come.
Mind you, I said nit pick comment alert. If you are just doing inline item renderers or things not requiring that level, Containers work.
I know what I am talking about, I have had some things blow up in my face, yeah that is what happens to inventors.
Campbell, it’s great to see there is someone that can fill my shoes right now with all of this stuff. HAHA
FYI, there is also some other interesting abnormalities that will come from item renderers dealing with height. You might need to set the Tree’s variableRowHeight to true if you are noticing weird measuring issues.
PS, I think you will love what I have come up with using itemRenderers on a large scale. Think out of the box on this one.
itemRenderer = (Module && dataAbstraction)
Peace, Mike
dude, I can’t see my caret cursor…
Hey Michael, welcome to my humble blog
Well people.. fore warned is fore armed. Michael has done some big components (you can see on his blog) so I would take what he says as good advice.
Yeah this was a small test which worked fine, but I hate things blowing up in my face… So get out your calculators people there might be some math in positioning things.
Cheers for the heads up dude. I like my cars with one transmision, fast, and hassel free.
Hmm “itemRenderer = (Module && dataAbstraction)” hmmmmmmmmm