一聚教程网:一个值得你收藏的教程网站

热门教程

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

时间:2022-06-28 22:14:54 编辑:袖梨 来源:一聚教程网

代码

 代码如下 复制代码

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 ")
}

热门栏目