2009-12-03 7 views

Répondre

0

J'espère que cela serait utile pour vous;)

public class BlocksTable extends DataGrid  
{ 
    public static const VALID_COLOR:uint = 0xDBAB21; 
    public static const INVALID_COLOR:uint = 0xC7403E; 

    public function BlocksTable() 
    { 
     super();   
    } 

    override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void 
    { 
     var contentHolder:ListBaseContentHolder = ListBaseContentHolder(s.parent); 
     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, 
            contentHolder.height - 
            y); 

     var g:Graphics = background.graphics; 
     g.clear(); 

     var fillColor:uint; 
     if(dataIndex < this.dataProvider.length) 
     { 
      if(this.dataProvider.getItemAt(dataIndex).IS_VALID) 
      { 
       fillColor = VALID_COLOR; 
      } 
      else 
      { 
       fillColor = INVALID_COLOR; 
      } 
     } 
     else 
     { 
      fillColor = color; 
     } 
     g.beginFill(fillColor, getStyle("backgroundAlpha")); 
     g.drawRect(0, 0, contentHolder.width, height); 
     g.endFill(); 
    } 
} 
Questions connexes