tags:

views:

457

answers:

4

I'm writing an Adobe Air client to a service similar to Twitter.

On the timeline (List component) I have a custom item renderer which is basically a Canvas with a fixed-width Image and a Text control, which is multi-line.

If the text is long enough to change the Canvas height, it will only be resized if I manually change the width of the Window, forcing a redraw of all renderers. If I simply scroll through the List, all "new" renderers will have the minimum height possible (which is the Image height).

Any ideas on how to force the re-measurement of the renderer when I set it's data?

Thanks in advance! :)

A: 

try calling invalidateSize() on the itemrender, and/or invalidateDisplayList() on the list

rogueg
I've tried that already. No success.
leolobato
I remember struggling with something similar, but I can't find the code. Try calling invalidateDisplayList() on another frame using the callLater function. You might also try validateNow(). Sorry I can't give you a specific solution.
rogueg
A: 

I'm struggling with similar invalidation / resizing issues. This video shed some light on building custom components for me. Hope it helps.

Here is a link to a great video of an adobe engineer speaking about creating components for flex in Action script.

http://tv.adobe.com/watch/max-2008-develop/creating-new-components-in-flex-3-by-deepa-subramaniam/

Joel
A: 

Did you try setting variableRowHeight=true for the list?

Amarghosh
I did. It does resize correctly if I change the window width. I just want it to recalculate and size it correctly when I am scrolling the list.
leolobato
how about setting the height of canvas and text to 100%
Amarghosh
A: 

If you handle the updateComplete event, you can recalculate the size there. It is probably over kill since updateComplete happens every time the itemrenderer is drawn but it works.

Leak