0
votes

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.

2
How are you defining a data change? When the dataProvider has been replaced? When the dataPRovider has elements removed, or added to it? Or something else?JeffryHouser
I'm using the same dataProvider instance. When I need to alter the list I just add/remove data from the dataProvider.Steve Kuo

2 Answers

1
votes

Why not add an EventListener to the ArrayCollection and give it a high priority? This would allow you to listen to update events on the data collection itself, and force your listener to occur first.

Edit: I've not tried this myself :^)

0
votes

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.