Why composite? Just add the label when you subclass.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of an0one Sent: Wednesday, June 18, 2008 7:22 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: How to compose a super tree item renderer using TreeItemRenderer and others I know how to create a subclass of TreeItemRenderer and use it as the itemRenderer of a Tree. What I can't quite figure out is how to create a composite tree item renderer enclosing a TreeItemRenderer and a Label. --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Alex Harui" <[EMAIL PROTECTED]> wrote: > > You may need to bind the new renderer's .data to the TreeITemRenderer's > .data property. > > > > I would just extend TreeItemRenderer and change what it does, though. > > > > ________________________________ > > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> ] On > Behalf Of an0one > Sent: Tuesday, June 17, 2008 8:18 AM > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] How to compose a super tree item renderer using > TreeItemRenderer and others > > > > Hi, > I want a custom tree item renderer that consists of a basic > TreeItemRenderer(to reuse its > tree node icons) and several other standard controls(they are also > IListItemRenderer > implementors). Let's call it ComboTreeItemRenderer, and to simplify the > matters, assume > it is composed of a TreeItemRenderer and a Label. > > This is my first try: > <mx:Tree width="100%" height="100%" > id="tagTree" > dataProvider="{myTags}" > change="handleTagSelection(event);"> > <mx:itemRenderer> > <mx:Component> > <mx:HBox> > <mx:TreeItemRenderer> > </mx:TreeItemRenderer> > <mx:Label text="[EMAIL PROTECTED]"> > </mx:Label> > </mx:HBox> > </mx:Component> > </mx:itemRenderer> > </mx:Tree> > > And the first error I met: > "Could not resolve <mx:TreeItemRenderer> to a component implementation." > > I don't believe TreeItemRenderer can not be used in mxml coding, so I > guess I was just not > coding in the right way. But what's the right way then? > > However, that's not really what I was stumped by, since I found that I > could write a custom > component(named MyTreeItemRenderer) which extends > TreeItemRenderer(nothing to > override, just to work around the "could no resolve" error), and it > could be resolved of > course. So here is my second try: > <mx:Tree width="100%" height="100%" > id="tagTree" > dataProvider="{myTags}" > change="handleTagSelection(event);"> > <mx:itemRenderer> > <mx:Component> > <mx:HBox> > <mx:MyTreeItemRenderer> > </mx:MyTreeItemRenderer> > <mx:Label text="[EMAIL PROTECTED]"> > </mx:Label> > </mx:HBox> > </mx:Component> > </mx:itemRenderer> > </mx:Tree> > > Now comes the really difficulties: I know I must assign values to some > properties of > MyTreeItemRenderer using information carried by data and listData, but > what properties > to assign value to? And what makes me even crazier is that I found > neither listData and > data was set(observed by overriding set listData and set data functions > and find they were > never called). > > Looking forward to seeing helpful hints. Thanks in advance. >