views:

43

answers:

1

You can hook into the creation of Flex 4 item renderers easily enough (through itemRenderer, or itemRendererFunction) allowing you to pull renderers from a custom object pool, but how would you put those renderers back into the pool?

I understand that layout virtualization does a form of object pooling, but I'd like a way to hook in to that. For example, when an itemRendererFunction has been assigned to a data group with a virtualized layout, item renderer construction is indeed deferred, but the instances are not re-used - I'd like to be able to intervene there, if possible.

But even in the case of normal virtualized renderers (where the instances are re-cycled) it would still be useful to be able to manage the pool manually. Pools could be shared between data groups, for example, to reduce the initial buffer required to populate each group.

Is there any way to know when Flex discards an item renderer instance? I have a sinking feeling that there is just no reliable way to tell - even though perhaps there should be.

Or, is there a crazy hack that could work (like keeping all renderers in the pool and testing their stage properties to determine availability)?

+1  A: 

Looks like SkinnableDataContainer is the place to start. Documentation suggests updateRenderer is the place to look at, but the code for it doesn't do much.

It also dispatches RendererExistenceEvent.RENDERER_ADD and RendererExistenceEvent.RENDERER_REMOVE events, which might be worth listening for if you are wanting to capture what's going on.

Gregor Kiddie
Awesome, that got me on the right track. RendererExistenceEvent.RENDERER_ADD/REMOVE events are dispatched from DataGroup.
Franky-D