I'm trying create a custom ItemRenderer for a list, and everything loads correctly and looks right, except that when I update the dataProvider in the list that uses the renderer, it never adds the horizontal scrollbar when the list items are too big. Instead, they just overflow.
Here's my code:
public class CategoryItemRenderer extends UIComponent implements IDropInListItemRenderer, IListItemRenderer, IDataRenderer
private var category:Category;
private var _listData:BaseListData;
private var nameLabel:Label;
private var slugLabel:Label;
public function CategoryItemRenderer()
public function get data():Object
public function set data(value:Object):void
category = value as Category;
public function get listData():BaseListData
public function set listData(value:BaseListData):void
_listData = value;
override protected function createChildren():void
nameLabel = new Label();
slugLabel = new Label();
* Called by the framework during init, also when you call invalidateProp=
override protected function commitProperties():void
nameLabel.text = category.name;
slugLabel.text = category.slug;
nameLabel.text = "";
slugLabel.text = "";
override protected function measure():void
measuredWidth = nameLabel.getExplicitOrMeasuredWidth() + slugLabel.getExplicitOrMeasuredWidth() + 20;
measuredHeight = nameLabel.getExplicitOrMeasuredHeight();
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
nameLabel.x = 0;
nameLabel.y = 0;
slugLabel.x = nameLabel.x + nameLabel.width + 10;
slugLabel.y = nameLabel.y;
I've searched through all the various online examples and tutorials, and combed this list, but I'm at a complete loss. No one seems to mention scrolling adjustments anywhere, or when they do, they talk about it like I should know what they're talking about. Am I just missing something completely obvious?
We're using Flex 3.5, so maybe this is just a 3.5 issue?
Have you tried doing this in a different type of item renderer...inline or mxml usually works pretty well in producing scroll bars since they are often formatted using containers... You're problem seems to be that you are trying to get a scroll bar to appear with a label, which won't happen because it's not a container. Try TextArea.
Thanks for the suggestion, but what I'm really trying to do is get the
scrollbar for the list itself to appear. I don't want the scrollbar on the
individual itemrenders. If any of the itemrenders is too big for the frame,
I want the entire list control to scroll, like it does when you use the
default renders and your item label is too long.