当前位置:软件学习 > Flash >>

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

代码

 代码如下 复制代码

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

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,