Thanks Bhuvan, that worked...

I added the following set property to my TreeItemRenderer class:
                public function set topicTitle(value:String):void {
                        _topicTitle = value;
                }

and the following to my mxml application:

        private function testRenderer() : void {                
        var myRenderer:ClassFactory = new ClassFactory
(samples.MyTreeItemRenderer);
        myRenderer.properties = {topicTitle:"GridRow"};
        compBalanced.itemRenderer = myRenderer 
        }


<mx:Tree id="compBalanced" dataProvider="{xlcBalanced}"  
labelField="@label"  itemOpen="testRenderer()"
        width="400" height="500"  />
</mx:Application>

This turns the leaf node containing the label GridRow red.  Now I can 
alter the code to pass the combobox selected item to the tree and 
style the rendering of the matching branches or leaves.

--- In [email protected], "Flexing..." <[EMAIL PROTECTED]> wrote:
>
> have a look at
> http://flex-apollo.blogspot.com/2007/05/single-itemrenderer-for- 
> multiple.html
> 
> On May 30, 2007, at 6:22 PM, sarah_e_boys wrote:
> 
> >
> > I would like to know how I pass a string (topicTitleParameter) in 
to
> > the extended TreeItemRenderer class below.
> >
> > package samples
> > {
> > import mx.controls.treeClasses.*;
> > import mx.collections.*;
> >
> > //Item renderer:
> > public class MyTreeItemRenderer extends TreeItemRenderer {
> >
> > public var topicTitle:String;
> >
> > // Define the constructor.
> > public function MyTreeItemRenderer
> > (topicTitleParameter:String) {
> > super();
> > this.topicTitle = topicTitleParameter;
> > }
> >
> > // Override the set method for the data property
> > // to set the font color and style of each node.
> > override public function set data(value:Object):void {
> > super.data = value;
> > if(TreeListData(super.listData).label ==
> > this.topicTitle ) {
> > setStyle("color", 0xff0000);
> > setStyle("fontWeight", 'bold');
> > }
> > else {
> > setStyle("color", 0x000000);
> > setStyle("fontWeight", 'normal');
> > }
> > }
> >
> > // Override the updateDisplayList() method
> > // to set the text for each tree node.
> > 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).item);
> > var myStr:int = tmp
> > [0].children().length();
> > super.label.text =
> > TreeListData(super.listData).label + "(" + myStr + ")";
> > }
> > }
> > }
> > }
> > }
> >
> > I tried the following:
> > <mx:Tree id="compBalanced" dataProvider="{xlcBalanced}"
> > labelFunction="treeLabel"
> > labelField="@label" width="400" height="500"
> > itemRenderer="samples.MyTreeItemRenderer('GridRow')" />
> >
> > and get the following error message:
> > Initializer for 'itemRenderer': cannot parse value of type
> > mx.core.IFactory from text 'samples.MyTreeItemRenderer('GridRow')'
> >
> >
> >
> >
>


Reply via email to