http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/spark/components/DataGroup.html#itemRendererFunction
( this is Flex 4, it didn't exist in Flex 3 )

But, no, it shouldn't work like that out of the box because renderers are
reused, when the list based control lays out a renderer it may use an old
one (since flex controls are in general very heavy, and it would be a huge
waste of resources to create them every time anew, or let you have a lot of
them in memory at a time). So, list based controls create the number of
visible renderers + 2-8 additional renderers for cases like scrolling.

If there aren't to many renderers, you could tell a parentDocument from
inside the item renderer, if the CB is checked, and then once the list
scrolls, the renderer would have it's data property reset, then, it could
check against parent document, and if it's index is registered as checked,
it would set the CB to checked, else, it would uncheck it.

Think of something like this:

public override function set data(value:Object):void
{
if ( this.parentDocument.amIChecked( this ) this.checkBox.checked = true;
else this.checkBox.checked = true;
super.data = value;
}

private function cb_clickHandler(event:MouseEvent):void
{
this.parentDocument.checkMe( this, (event.currentTarget as
CheckBox).checked);
}

/* parent document */

public function amIChecked(renderer:ItemRenderer):Boolean
{
return this._allCheckedArray[dg.itemIndex(renderer)];
}

public function checkMe(renderer:ItemRenderer, checked:Boolean):void
{
return this._allCheckedArray[dg.itemIndex(renderer)] = checked;
}

Reply via email to