|
Hello Flexcoders; I’m trying to write a list item renderer that alternates
its background color based on its position in its parent list’s data
provider. I know I could use the alternatingItemColors style on the list, but I
don’t like the way it’s implemented. (Even rows with no content get
the alternating colors. IMHO, empty rows should look like empty rows.) My item renderer implements IDropInListItemRenderer and
caches the rowIndex parameter of the list data in a bindable attribute. However,
if you run the test application included at the bottom of this email, you’ll
see that the rowIndex parameter is incorrect when the list is scrolled. When
scrolling down, items added to the bottom of the list get the same rowIndex as
the item above them. When scrolling up, items added to the top of the list
always get rowIndex 0. The rowIndex parameters can be re-established with the
correct values by making some change to the list that forces it to redraw. For
instance, changing the rowHeight parameter. Is this a bug, or am I doing something wrong? Thanks. Tobias. Kodak Graphic Communications Canada Company Tobias Patton | Software Developer | Tel: +1.604.451.2700
ext: 5148 | mailto:[EMAIL PROTECTED] | http://www.creo.com <?xml version="1.0" encoding="utf-8"?> <mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"> <mx:ArrayCollection
id="ac"> <mx:String>Zero</mx:String> <mx:String>One</mx:String> <mx:String>Two</mx:String> <mx:String>Three</mx:String> <mx:String>Four</mx:String> <mx:String>Five</mx:String> <mx:String>Six</mx:String> <mx:String>Seven</mx:String> <mx:String>Eight</mx:String> <mx:String>Nine</mx:String> <mx:String>Ten</mx:String> </mx:ArrayCollection> <mx:List id="l1"
width="100" height="200"> <mx:dataProvider>{ac}</mx:dataProvider> <mx:itemRenderer> <mx:Component> <mx:VBox horizontalScrollPolicy="off" implements="mx.controls.listClasses.IDropInListItemRenderer"> <mx:Script> <![CDATA[ import
mx.controls.List; import
mx.controls.listClasses.BaseListData; private
var _listData : BaseListData; public
function get listData() : BaseListData { return
_listData; } public
function set listData( value : BaseListData ) : void { _listData
= value; rowIndex
= _listData.rowIndex; } [
Bindable ] public
var rowIndex : Number = -1; ]]> </mx:Script> <mx:Label
text="{String( rowIndex ) + ' ' + String( data )}"/> </mx:VBox> </mx:Component> </mx:itemRenderer> </mx:List> <mx:Button
label="Refresh" click="RefreshRowIndices()"/> <mx:Script> <![CDATA[ private
function RefreshRowIndices() : void { var
r : Number = l1.rowHeight; l1.rowHeight
= -1; l1.rowHeight
= r; } ]]> </mx:Script> </mx:Application> -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com YAHOO! GROUPS LINKS
__,_._,___ |

