CS5 中禁用SimpleButton

需要在CS5中对一个SimpleButton设置禁用效果,即不响应鼠标,同时颜色变灰.

使用enabled属性发现不好使,还是会响应鼠标事件,最后发现mouseEnabled = false就好用了。

 

变灰是使用了滤镜效果,参考自:as3.0 用代码设置“调整颜色”滤镜--------即:亮度、对比度、饱和度、色相的调整

 

最终代码如下:

pre.mouseEnabled = false;

var bh_Matrix:ColorMatrix=new ColorMatrix();

var bh_Filter:ColorMatrixFilter=new ColorMatrixFilter();

bh_Matrix.SetSaturationMatrix(0);//设置饱和度值,值的大小是 -255--255 1为中间值,0为灰度值即黑白相片

bh_Filter.matrix = bh_Matrix.GetFlatArray();

pre.filters = [bh_Filter];

你可能感兴趣的:(button)