var bmpd:BitmapData; var matrix:Matrix; var bmp:Bitmap; var size:Number = 5; /** * @author:Frost.Yen * @E-mail:871979853@qq.com */ function mosaic(source:MovieClip,size:Number):void { if (bmpd) { bmpd.dispose(); } if (matrix) { matrix = null; } bmpd = new BitmapData(source.width / size,source.height / size,true,0); matrix = new Matrix ; matrix.scale(1 / size, 1 / size); bmpd.draw(source, matrix); bmp = new Bitmap(bmpd); source.addChild(bmp); bmp.width = source.width; bmp.height = source.height; } mc.addEventListener(MouseEvent.CLICK,_chang); function _chang(e:MouseEvent):void { mosaic(mc,size); mc.mouseEnabled = false; }