用BitmapData类实现的动态毛玻璃效果
作者:admin 日期:2012-01-09
在蓝色论坛中看到一个网友的问题,结合我前面做农信社项目时的一些经验,写了一个小测试。放上去给大家分享一下,源代码下载点击这里点击下载此文件
package
{
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.ui.Mouse;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.filters.BlurFilter;
import flash.filters.BitmapFilterQuality;
public class test extends MovieClip
{
var _bmd:BitmapData;
var _bmdback:BitmapData;
public function test()
{
_bmd = new BitmapData(100,100);
_bmdback = new BitmapData(360,500);
addEventListener(Event.ENTER_FRAME,auto);
}
function auto(e:Event):void
{
_mc.x = mouseX;
_mc.y = mouseY;
var _rect = new Rectangle(_mc.x,_mc.y,100,100);
_bmdback.draw(_back);
_bmd.copyPixels(_bmdback, _rect, new Point(0, 0));
_mc._cont.addChild(new Bitmap(_bmd));
var gradientBevelFilter:BlurFilter = new BlurFilter(5,5,BitmapFilterQuality.HIGH);
var filtersArray:Array = new Array(gradientBevelFilter);
_mc._cont.filters = filtersArray;
}
}
}