Reputation: 63104
I need to detect when a Flex Spark List (spark.components.List
) data has changed so that I can programmatically change its scrollbar.
I know that List is a an EventDispatcher but it's unclear which event I'd register for.
Edit: My List's dataProvider is an ArrayCollection that elements are added too. So the dataProvider is never replaced. I considered listening to the backing ArrayCollection, but it's possible the List will react to the change after my listener, which alters the scrollbar. Thus my listener's changes will be superseded by that of the List.
Upvotes: 0
Views: 1255
Reputation: 283
I don't know if it's still the case or not! But you could do following: Implement an itemRenderer for your spark list and use 'dataChange' attribute of your itemRenderer to see when your data has been changed? Something like this:
Your list:
<s:List id="myList" dataProvider="{myArrayCollection}"
itemRenderer="myItemRenderer" ...>
</s:List>
Now on your itemRenderer
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
dataChange={invalidateDisplayList()} >
</s:ItemRenderer>
For example in my case I was trying to delete each items of my list, and after that my itemRenderer could update itself Automatically through 'dataChange'...
Although you can use others such as invalidateSize()
, invalidateLayering()
and etc regarding your needs.
Upvotes: 0