I have tried extending the TreeItemRenderer class similar to your 
example, the problem that I have is that the item is still rendered 
by a single label.  It's not clear to me how I can create a more 
complex item renderer, for example, one that consists of a label and 
an image.
Is there a way to do this in flex 2 short of writing a custom 
renderer that handles it's own indentation and controls?
Thanks.

--- In flexcoders@yahoogroups.com, "Joan Tan" <[EMAIL PROTECTED]> wrote:
>
> You cannot just drop in any renderer for a Tree component or Menu 
which
> need to deal with indentation because your renderer doesn't know
> anything about it. Instead, the easiest thing to do is to use an
> itemRenderer that subclasses the TreeItemRenderer class. Here is an
> example of a Tree item renderer. The renderer will change the font
> weight and color of parent nodes and add text as to how many 
children
> each node has.
> 
>  
> 
>  
> 
> package 
> 
> {
> 
>  
> 
> import mx.controls.treeClasses.*;
> 
> import mx.collections.*;
> 
>  
> 
>             public class MyTreeItemRenderer extends 
TreeItemRenderer
> 
>             {
> 
>                         
> 
>                 public function MyTreeItemRenderer() 
> 
>                 {
> 
>                          super();
> 
>                          mouseEnabled = false;
> 
>                                     
> 
>                 }
> 
>                         
> 
>                 override public function set data
(value:Object):void
> 
>                 {
> 
>                          super.data = value;
> 
>                          if(TreeListData
(super.listData).hasChildren)
> 
>                          {
> 
>                              setStyle("color", 0xff0000);
> 
>                              setStyle("fontWeight", 'bold');
> 
>                         }
> 
>                         else
> 
>                         {
> 
>                              setStyle("color", 0x000000);
> 
>                              setStyle("fontWeight", 'normal');
> 
>                         }
> 
>                 }
> 
>              
> 
>                override protected function
> updateDisplayList(unscaledWidth:Number,  
unscaledHeight:Number):void
> 
>                {
> 
>                         super.updateDisplayList(unscaledWidth,
> unscaledHeight);
> 
>                         if(super.data)
> 
>                         {
> 
>  
> if(TreeListData(super.listData).hasChildren)
> 
>                               {
> 
>                                      var tmp:XMLList = new
> XMLList(TreeListData(super.listData).node);
> 
>                                      var myStr:int =
> tmp[0].children().length();
> 
>                                      super.label.text =
> TreeListData(super.listData).text + "(" + myStr + ")";
> 
>                              }
> 
>                        }
> 
>               }
> 
>       }
> 
> }
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com 
[mailto:[EMAIL PROTECTED] On
> Behalf Of pasflex
> Sent: Wednesday, March 22, 2006 9:52 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Tree itemRenderer - flex 2
> 
>  
> 
> When setting an itemRenderer for a tree in flex2, the tree 
controls 
> and indentation disappear.  For example, if I try to display a 
label 
> and an image for each node in the tree and I create an 
itemrenderer to 
> do so, the tree will only display the root node using the 
itemrenderer 
> with no controls to open it (basically turning the tree into a one 
> item list).
> In flex 1.5 a cellrenderer assigned to a tree didn't override the 
> default tree behavior, it only changed the renderering of the item 
in 
> the node.
> How does one accomplish this is flex2?
> 
> Thanks
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> 
> 
> 
> 
> ________________________________
> 
> YAHOO! GROUPS LINKS 
> 
>  
> 
> *      Visit your group "flexcoders
> <http://groups.yahoo.com/group/flexcoders> " on the web.
>         
> *      To unsubscribe from this group, send an email to:
>        [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]
subject=Unsubscribe> 
>         
> *      Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> . 
> 
>  
> 
> ________________________________
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to