Actionscript 3 在mx:datagrid中使SelectionColor透明

Actionscript 3 在mx:datagrid中使SelectionColor透明,actionscript-3,flash,apache-flex,flex3,Actionscript 3,Flash,Apache Flex,Flex3,我在flex应用程序中使用mx:DataGrid组件。我展示了这样一个网格: 我想将选定的蓝色更改为透明。我正在使用以下代码: <mx:DataGrid id="dg" dataProvider="{arrDg}" width="100%" height="100%" draggableColumns="false" rowCount="{arrDg.length}" click="dgClickHandler(event)" variableRowHeight="t

我在flex应用程序中使用mx:DataGrid组件。我展示了这样一个网格:

我想将选定的蓝色更改为透明。我正在使用以下代码:

<mx:DataGrid id="dg" dataProvider="{arrDg}" width="100%" height="100%" 
    draggableColumns="false" rowCount="{arrDg.length}" click="dgClickHandler(event)" 
    variableRowHeight="true" resizableColumns="false" sortableColumns="false" 
    selectionColor="#00000000" verticalScrollPolicy="off">

但是这会将颜色改为黑色而不是透明


请帮助。

[编辑[

哎呀,我没注意到那个颜色有8个零。Flash不支持RGBA(或带有alpha/透明度的颜色值)

[结束编辑]

如果您根本不希望在选择时显示任何突出显示,请尝试将(mx)
DataGrid
的属性设置为
false
。似乎您有一个单击处理程序,关闭选择可能会阻止单击处理程序执行其任务:(


如果您确实需要某种类型的选择指示器,但想修改选择颜色的alpha(透明度),则该样式设置不存在(即:没有“selectionAlpha”样式)。您必须创建一个自定义数据网格类才能做到这一点。

[Edit[

哎呀,我没注意到那个颜色有8个零。Flash不支持RGBA(或带有alpha/透明度的颜色值)

[结束编辑]

如果您根本不希望在选择时显示任何突出显示,请尝试将(mx)
DataGrid
的属性设置为
false
。似乎您有一个单击处理程序,关闭选择可能会阻止单击处理程序执行其任务:(


如果您确实需要某种类型的选择指示器,但想修改选择颜色的alpha(透明度),则该样式设置不存在(即:没有“selectionAlpha”样式)。您必须创建自定义数据网格类才能执行此操作。

如果需要选择
mx:DataGrid
,但也希望选择颜色不影响单元格/行的颜色,则可以使用此方法:

扩展
DataGrid
覆盖函数
drawSelectionIndicator
,并将函数内容保留为空(您也可能有兴趣覆盖
drawHighlightIndicator
函数)


如果需要选择
mx:DataGrid
,但也希望选择颜色不影响单元格/行的颜色,则可以使用以下方法:

扩展
DataGrid
覆盖函数
drawSelectionIndicator
,并将函数内容保留为空(您也可能有兴趣覆盖
drawHighlightIndicator
函数)

将“可选”设置为false完成了此操作,我还删除了单击处理程序。将“可选”设置为false完成了此操作,我还删除了单击处理程序。
public class CustomRowColorDataGrid extends DataGrid
{
    public function CustomRowColorDataGrid()
    {
        super();
    }

    override protected function drawSelectionIndicator(indicator:Sprite, x:Number, y:Number, w:Number, h:Number, color:uint, itemRenderer:IListItemRenderer):void
    {
        //If you want a rectangle arround the selected row use call this method 
        //Rectangle(indicator,x,y,0xFF9900, 2,h) ;
    }

    override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, w:Number, h:Number, color:uint, itemRenderer:IListItemRenderer):void
    {
        Rectangle(indicator,x,y,highlight, 2,h) ;
    }

    private function Rectangle(indicator:Sprite, xx:int, yy:int,colorBorde:uint,grosor:int, h:int):void
    {
        var g:Graphics ;
        var w:int ;

        w = this.width - this.verticalScrollBar.width-1 ;

        g = Sprite(indicator).graphics;
        g.clear();
        g.lineStyle(grosor,colorBorde) ;
        g.drawRect(0,1,w-grosor,h-grosor) ;

        indicator.x = xx;
        indicator.y = yy;
    }       
}