---
title: "CS5 中禁用SimpleButton"
author: "cuixuxucui"
date: "2011-12-09T11:48:11Z"
tags: []
categories: ["Web前端"]
slug: "cs5-simplebutton"
draft: false
lastmod: "2011-12-09T11:48:11Z"
id: 1299769
url: "https://smartblack.iteye.com/blog/1299769"
---

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

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

 

变灰是使用了滤镜效果，参考自：[as3.0 用代码设置“调整颜色”滤镜--------即：亮度、对比度、饱和度、色相的调整](http://hi.baidu.com/wangyunzhao525/blog/item/bab419024703dd154afb516f.html)

 

最终代码如下：

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];