/*
AS3.0包括9个滤镜
斜角滤镜(BevelFilter 类)
模糊滤镜(BlurFilter 类)
投影滤镜(DropShadowFilter 类)
发光滤镜(GlowFilter 类)
渐变斜角滤镜(GradientBevelFilter 类)
渐变发光滤镜(GradientGlowFilter 类)
颜色矩阵滤镜(ColorMatrixFilter 类)
卷积滤镜(ConvolutionFilter 类)
置换图滤镜(DisplacementMapFilter 类)
前6个为简单滤镜,后3个为复杂滤镜.复杂滤镜只能由actionscript创建
*/
/*库中有个元件链接为kt
//1.斜角滤镜(BevelFilter类)
var mc:MovieClip=new kt();
mc.x=400;
mc.y=300;
addChild(mc);
var bevel:BevelFilter = new BevelFilter();
bevel.distance = 5;//斜角的偏移距离
bevel.angle = 45;//斜角的角度
bevel.highlightColor = 0xFFFF00;//斜角加亮色
bevel.highlightAlpha = 0.8;//加亮色的透明度
bevel.shadowColor = 0x666666;//斜角阴影色
bevel.shadowAlpha = 0.8;//阴影色的透明度
bevel.blurX = 5;//水平模糊量
bevel.blurY = 5;//垂直模糊量
bevel.strength = 5;//印记或跨页的强度
bevel.quality = BitmapFilterQuality.HIGH;//应用滤镜的次数
bevel.type = BitmapFilterType.INNER;//斜角在对象上的位置
bevel.knockout = false;//应用挖空效果
mc.filters = [bevel];// 对图像应用滤镜
*/
/*
//2.模糊滤镜(BlurFilter 类)
var mc:MovieClip=new kt();
mc.x=400;
mc.y=300;
addChild(mc);
var blur:BlurFilter = new BlurFilter();
blur.blurX = 10;//水平模糊
blur.blurY = 10;//垂直模糊
blur.quality = BitmapFilterQuality.MEDIUM;//应用滤镜次数(2),LOW为(1),HIGH(3)
mc.filters = [blur];// 对图像应用滤镜
*/
//下面做一个渐变的模糊滤镜,达到鼠标指针进入位图后图片渐变模糊,指针移出后位图复原
var mc:MovieClip=new kt();
mc.x = 400;
mc.y = 300;
addChild(mc);
var blur:BlurFilter = new BlurFilter();
blur.blurX = 0;//水平模糊
blur.blurY = 0;//垂直模糊
blur.quality = BitmapFilterQuality.LOW;//应用滤镜次数
mc.filters = [blur];// 对图像应用滤镜
var ktt:Boolean = false;
mc.addEventListener(MouseEvent.MOUSE_OVER,onClickOver);
function onClickOver(e:MouseEvent):void
{
ktt = true;
}
mc.addEventListener(MouseEvent.MOUSE_OUT,onClickOut);
function onClickOut(e:MouseEvent):void
{
ktt = false;
}
mc.addEventListener(Event.ENTER_FRAME,onOver);
function onOver(e:Event):void
{
if (blur.blurX <= 10 && ktt == true)
{
blur.blurX += .5;
blur.blurY += .5;
mc.scaleX -= 0.01;
mc.scaleY -= 0.01;
}
if (blur.blurX > 0 && ktt == false)
{
blur.blurX -= .5;
blur.blurY -= .5;
mc.scaleX += 0.01;
mc.scaleY += 0.01;
}
mc.filters = [blur];
}