Hi Alex,

I found some examples that did it that way. At first I tried setting the
style on the itemrenderer itself or otherways just affecting the node - but
to no avail.

This way works the way I excpect (the nodes get an icon based on their type)
- *except* for the NullPointerException/TypeError that is ;-)

If you have a better solution please let me know.

I'll try to reproduce it with a testcase.

Bjørn



On 30/08/2007, Alex Harui <[EMAIL PROTECTED]> wrote:
>
>    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\mx\controls\Tree.as:1048<http://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
>
> 
>



-- 

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

Reply via email to