Hi Neil,
the item renderer will be reused in a list after an item is outside the
visible area. You could "save" the state to the underlying data. In your
item renderer you could override the commitProperties method:
private function buttonExpandedHandler(event:Event):void {
// pressing the button
data["ExpandedState"] = (data["ExpandedState"] != true );
// Change state with effects
}
//
protected override function commitProperties():void {
super.commitProperties();
var expandedState:Boolean = ( data && data["ExpandedState"] ) ;
// Change state if necessary without effect
}
When an item renderer will be reused, the underlying item will be set by the
framework with the data property which calls invalidateProperty. The code is
not tested, but it should work.
Please excuse my English,
Harald
Von: [email protected] [mailto:[EMAIL PROTECTED] Im
Auftrag von nwebb
Gesendet: Sonntag, 25. Februar 2007 14:04
An: flexcoders
Betreff: [flexcoders] Problem with List Item Renderer (and states)
Hi,
I have a custom item renderer with two states (expanded and collapsed)
My items are displayed in a List component, and the data is currently coming
from an ArrayCollection.
You can see the page here (click on "Gig Calender"):
http://www.bathbands.co.uk/test2007/
Here is an example of the problem I'm facing:
1) Click the "Read More" button of the first item in the List - it will
expand.
2) Scroll down and you can see that the third and last item have also
expanded.
3) Scroll back up and you will see that the first item is now in the
collapsed state again, but other items are now in the expanded state.
I'm not sure what's causing the other items to open/close. I guess it has
something to do with Flex redrawing stuff as it goes off screen, and would
appreciate suggestions on how best to prevent this kind of thing from
happening.
Cheers,
Neil