Hi,

I have to color the nodes shown in my adg. The code below do the job but 
the performances insanely decrease. Any idea how to improve it please?

Best regards,

Henry

override protected function drawRowBackground(s:Sprite, rowIndex:int,
                                                                                
                          y:Number, height:Number, color:uint, 
dataIndex:int):void
                {
                        //default background alpha
                        var alpha:Number = 1.0;
                        if (dataProvider is HierarchicalCollectionView)
                        {
                                
                                var cursor:IViewCursor = 
dataProvider.createCursor();
                                var index:int=0;
                                // move on the current row
                                while (index < dataIndex)
                                {
                                        index++;
                                        cursor.moveNext();
                                }
                                // if the current row is a node, then set the 
color
                                // and the background alpha (the deeper, the 
darker)
                                
if(dataProvider.source.canHaveChildren(cursor.current)){
                                        color = 0x25e16d;
                                        alpha = 
dataProvider.getNodeDepth(cursor.current) / 10;
                                        if (alpha > 1) alpha = 1;
                                }
                        }
                        
                        var background:Shape;
                        if (rowIndex < s.numChildren)
                        {
                                background = Shape(s.getChildAt(rowIndex));
                        }
                        else
                        {
                                background = new FlexShape();
                                background.name = "background";
                                s.addChild(background);
                        }
                        
                        background.y = y;
                        
                        // Height is usually as tall is the items in the row, 
but not if
                        // it would extend below the bottom of listContent
                        var height:Number = Math.min(height,
                                listContent.height -
                                y);
                        
                        var displayWidth:int = unscaledWidth - 
viewMetrics.right - viewMetrics.left;
                        var g:Graphics = background.graphics;
                        g.clear();
                        g.beginFill(color, alpha);
                        g.drawRect(0, 0, displayWidth, height);
                        g.endFill();
                }

Reply via email to