AS3 – mx:List with ItemRenderer Scrolling Problem

AS3 – mx:List with ItemRenderer Scrolling Problem

ItemRenderer class instances in AS3 are re-used when rendering objects in mx:List. For example, if you provide 500 elements to the list’s dataProvider, and only showing 10 rows in the list output, it will create around just over 10 instances of your ItemRenderer. And every time you scrolls the list, it will use the existing renderers to render those new elements in the list by simply calling the “set data” method. It will be up to you to update the state of the renderer yourself, otherwise you will expect very weird behaviours. So you will need to do update your set data function:
override public function set data(value:Object):void {

    // need to remember to call this 
    super.data = value;
    /* then insert code here to update the state of the renderer */
}

Leave a Reply

Your email address will not be published.

My new Snowflake Blog is now live. I will not be updating this blog anymore but will continue with new contents in the Snowflake world!