Thanks to everyone who has put forward a suggestion so far :).

My List is populated with an ArrayCollection of Typed objects (of type
Band).

Obviously my Band class should not have the responsibility of storing the
current state (expanded/collapsed) - or even knowing anything about it, so I
am wondering if the data property and the Band instance are indeed the same
thing here?
If they are, it doesn't sound ideal to add stuff to the data object - or is
this not the case?

Cheers,
Neil




On 2/25/07, Harald Dehn <[EMAIL PROTECTED]> wrote:

   There is a better solution solution:



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

}





Harald





*Von:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *Im
Auftrag von *shuell2000
*Gesendet:* Sonntag, 25. Februar 2007 16:16
*An:* flexcoders@yahoogroups.com
*Betreff:* [flexcoders] Re: Problem with List Item Renderer (and states)



Your problems stem from the fact that Lists reposition and resize
children each time updateDisplayList is called. Which is whenever you
scroll or resize any of their children. List components extend
TileBase which has a method called makeRowsAndColumns which is the
method that is causing you frustration at the moment. Lists were not
meant to hold itemRenderers that can resize themselves. Instead Lists
have built in mouseOver and mouseDown handlers that recolor the
background behind the object causing the mouseEvent and they must have
thought that would be good enough. I recently had to rewrite the list
classes to allow a resize to work on mouseOver of its children. It
was an ugly hack but the project timeline did not allow me to do much
more at the moment. Basically I created my own Tilebase and ListBase
classes then changed the updateDisplayList method and the
makeRowsAndColumns method to leave alone any itemRenderer that was not
in its default state. Aside from a few issues caused by this, it
seems to have solved my issue but is hardly clean enough to post here.
Take a look at those methods I mentioned and see if you can't do
something in them to ignore anything that is transitioning to a new
state or in a new state.

Good Luck,

John Shuell

--- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, nwebb
<[EMAIL PROTECTED]> wrote:
>
> 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
>

Reply via email to