As3.0图片变马赛克效果代码

作者:袖梨 2022-06-28

代码

 代码如下 复制代码

var pixBitMapData:BitmapData;
var theScaleMatrix:Matrix;
var pixMap:Bitmap;
var maisaikeshuliang:Number=50;
var my_Spr:Sprite;

function _masaike(oldDataMovieClip:MovieClip,p:Number):void {
  if (pixBitMapData) {
    pixBitMapData=null;
  }
  if (theScaleMatrix ) {
    theScaleMatrix =null;
  }
  pixBitMapData = new BitmapData(oldDataMovieClip.width / p, oldDataMovieClip.height /p, true, 0);
  theScaleMatrix = new Matrix;
  my_Spr=new Sprite();
  theScaleMatrix.scale(1 / p, 1 / p);
  pixBitMapData.draw(oldDataMovieClip, theScaleMatrix);
  pixMap = new Bitmap(pixBitMapData);
  oldDataMovieClip.addChild(pixMap);
  //oldDataMovieClip.addChild();
  pixMap.addEventListener(MouseEvent.CLICK,getColor)
  pixMap.width = oldDataMovieClip.width;
  pixMap.height = oldDataMovieClip.height;
}
mc.addEventListener(MouseEvent.CLICK,_chang);
function _chang(e:MouseEvent):void {
  _masaike(mc,maisaikeshuliang);
  mc.mouseEnabled=false;
}
function getColor(e:MouseEvent):void{
  trace("get it ")
}

相关文章

精彩推荐