Yeah, Tree doesn't like having styles set on it during a scroll, especially from a renderer. You might actually be setting up an infinite invalidation loop. You're welcome to file a bug so we can make it less sensitive, and maybe we should make it easier to override the logic for icons. Also, setStyle is expensive, and is really telling the Tree that all icons for all rows should be changed. In your case, I would recommend subclassing Tree, overriding makeListData, and setting the disclosure icon there.
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of bjorn - Sent: Friday, August 31, 2007 5:04 AM To: [email protected] Subject: Re: [flexcoders] TypeError in ListBase.as when using setStyle() in custom TreeItemRenderer For your viewing pleasure, here's a simple testcase: http://www.juicability.com/treetest/ <http://www.juicability.com/treetest/> Source is also available there... Bjørn On 31/08/2007, bjorn - <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: 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] <mailto:[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] ups.com <http://ups.com/> [mailto: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ups.com <http://ups.com/> ] On Behalf Of bjorn - Sent: Thursday, August 30, 2007 4:47 AM To: [EMAIL PROTECTED] ups.com <http://ups.com/> 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 <http://ent.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 -- ======================== http://www.juicability.com <http://www.juicability.com/> - flex blog http://www.43min.com <http://www.43min.com/> - funny movies -- ======================== http://www.juicability.com <http://www.juicability.com> - flex blog http://www.43min.com <http://www.43min.com> - funny movies

