Hi, I solicite you because I encounter a problem with an itemRenderer. I develop an application that displays data from a sensor in a DataGrid. there are several changes per second on my dataProvider (ArrayCollection) and I want to put the cell background in green if the value increases or in red if it decrease. Unfortunately, all changes in the dataProvider does not modify the background of my itemRenderer.
[BEGIN ItemRenderer] package renderer { import flash.display.Graphics; import flash.events.Event; import mx.controls.Label; import mx.controls.dataGridClasses.*; import mx.events.ResizeEvent; [ Style(name="backgroundColor", type="uint", format="Color", inherit="no")] public class BGRenderer extends Label { private var g:Graphics; private var cpt:int = 0; private var old:Number = 0; private var color:uint = 0; public function BGRenderer():void { super(); this.addEventListener(ResizeEvent.RESIZE, resize); g = graphics; g.clear(); } private function clear(ev:Event):void { if(++cpt == 25) { this.removeEventListener(Event.ENTER_FRAME, clear); g.clear(); } } private function resize(ev:ResizeEvent):void { if(color != 0) { g.clear(); g.beginFill(color); g.drawRect(0, 0, unscaledWidth, unscaledHeight); g.endFill(); } } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); var val:Number = new Number(data[DataGridListData(listData).dataField]); if (!isNaN(val) && val != old) { cpt = 0; this.removeEventListener(Event.ENTER_FRAME, clear); g.clear(); if(val < old) { color = 0xFF0000; g.beginFill(0xFF0000); } else { color = 0x00FF00; g.beginFill(0x00FF00); } old = val; g.drawRect(0, 0, unscaledWidth, unscaledHeight); g.endFill(); this.addEventListener(Event.ENTER_FRAME, clear); } } } } [END ItemRenderer] to change data in my data provider I use this code: private var valeurDP:ArrayCollection;public function set temperature(val:String, iSonde:Number):void { var tmp:Object = valeurDP[iSonde]; tmp.temperature = val; valeurDP.setItemAt(tmp, iSonde); } -- You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to flex_in...@googlegroups.com. To unsubscribe from this group, send email to flex_india+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.