Maybe a bug.  Do you have a simple test case?

 

However, why would you set styles on the tree in each renderer?  I would
think there'll be other problems with that.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of bjorn -
Sent: Thursday, August 30, 2007 4:47 AM
To: [email protected]
Subject: [flexcoders] TypeError in ListBase.as when using setStyle() in
custom TreeItemRenderer

 

 

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\m
x\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 <http://www.juicability.com>  - flex blog
http://www.43min.com <http://www.43min.com>  - funny movies 

 

Reply via email to