What is the proper way to set the icon from a TreeItemRenderer when 
using an embeded graphic file?  I don't want to accidentally create 
hundreds of instances of it in memory.  TreeItemRenderer.icon is an 
instance of IFlexDisplayObject which is implemented by BitmapDataAsset 
(the embedded graphic class).  When I do the following:

   public class MyTreeItemRenderer extends TreeItemRenderer
    {

        [Embed(source="../../assets/test.jpg")]
        public var testIcon:Class;
     
        public function MyTrereItemRenderer() {
            super();
        }
        
     
        // 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);            
            this.icon = new studentIcon();
        }
    }


I get this RTE:

ArgumentError: Error #2025: The supplied DisplayObject must be a child 
of the caller.
        at flash.display::DisplayObjectContainer/removeChild()
        at 
mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::$remo
veChild()
        at mx.core::UIComponent/removeChild()
        at 
mx.controls.treeClasses::TreeItemRenderer/commitProperties()
        at mx.core::UIComponent/validateProperties()
        at mx.managers::LayoutManager/validateClient()
        at mx.controls::List/makeRowsAndColumns()
        at 
mx.controls.listClasses::ListBase/makeRowsAndColumnsWithExtraRows()
        at mx.controls.listClasses::ListBase/updateDisplayList()
        at mx.controls::List/updateDisplayList()


I can't seem to find a good example of a TreeItemRenderer on the web 
that uses the icon field to control the icon.

Dave

Reply via email to