hi list, first post... i have an architectural question about datatproviders and itemrenderers that i'll pose with a canonical example.
suppose i have an array of StockInfo objects that is populated by a 3rd party library. each StockInfo object dispatches UPDATE events when a stock price changes. i want to render the prices in HorizontalList with a custom renderer. here's the general application shell: ========================= <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="applicationCompleteListener(event)"> <mx:Script> <![CDATA[ import mx.controls.HorizontalList; import mx.events.FlexEvent; import mx.core.ClassFactory; protected var list:HorizontalList; protected var stocks:Array; protected function applicationCompleteListener (e:FlexEvent):void { // Stock data (hardcoded for the example) stocks = [new StockInfo()]; // UI list = new HorizontalList(); list.width = 400; list.height = 100; list.itemRenderer = new ClassFactory(StockInfoRenderer); addChild(list); } ]]> </mx:Script> </mx:Application> ========================= i need to wire the stocks array to the list. of course, given that i already have an array of StockInfo objects, it's tempting to make an ArrayCollection wrapper that gives direct access to the StockInfo objects. e.g., provider = new ArrayCollection(); provider.addItem({stockInfo:someStockInfoObject}); then the StockInfoRenderer could register for UPDATE events and redraw when the event occurs. but i'm hesitant about that approach. if i went that route, 1) within the StockInfoRenderer, where would i register for the UPDATE event? in commitProperties()? 2) within the StockInfoRenderer, where would i *remove* the UPDATE listener? 3) given that renderers are reused, are there issues with synching, or with stranded listeners causing memory build-up? more generally, what's the right way to wire my list to the stocks array? it feels like i might be forced to handle UPDATE for each StockInfo object, and write a 'price' variable into a data provider. e.g., provider.getItemAt(i).price = value; provider.itemUpdated(provider.getItemAt(i), "price"); seems a shame, given that i already have an array of StockInfo objects. the above two lines presuppose that i'm going to hunt for the item index every time a stock price changes. : ( another general question, do i even need the itemUpdate() call, or is that part automated? thanks for any advice! flexrookie

