I have made a custom TreeItemRenderer and overridden the set data function
to change the icon according to the data.

This is done something like this:


        override public function set data(value:Object):void
        {
         super.data = value;
         if(value != null) {

                    var myListData:TreeListData = TreeListData(this.listData
);
                    if (myListData) {
                            var fileObject:Object = value;
                            var _tree:Tree = Tree(myListData.owner);
                            if(fileObject.isMovie) {
                                     _tree.setStyle('defaultLeafIcon',
this.movieIcon );
                                     _tree.setStyle('folderClosedIcon',
this.movieIcon );
                                     _tree.setStyle('folderOpenIcon',
this.movieIcon )
                            }
                        }
          }
Hower, in some cases I get this exception:
TypeError: Error #1009: Cannot access a property or method of a null object
reference.
 at mx.controls.listClasses::ListBase/styleChanged
()[E:\dev\flex_201_borneo\sdk\frameworks\mx\controls\listClasses\ListBase.as:3062]
 at mx.controls::Tree/styleChanged
()[E:\dev\flex_201_borneo\sdk\frameworks\mx\controls\Tree.as:1048]
 at mx.core::UIComponent/setStyle
()[E:\dev\flex_201_borneo\sdk\frameworks\mx\core\UIComponent.as:7222]
...


It's the styleChanged() method in ListBase.as which throws the error - on
this line:
var m:int = listItems[i].length;

.. so, it seems listItems[i] is null ?

Why? :-)


-- 

========================
http://www.juicability.com - flex blog
http://www.43min.com - funny movies

Reply via email to