马赛克效果

来源:百度文库 编辑:神马文学网 时间:2024/06/04 19:21:45

制作过程

1、导入一张图至库

2、将图拖到场景,对齐,选中图,转换为影片剪辑元件

3、选中影片剪辑,打开动作面板,输入如下语句

把下列语句拖黑复制到动作面板

onClipEvent(load){
 numY=40;
 numX=55;
 numPerFrame=24;
 currSquare=0;
 choices=new Array();
 for (i=0;i  choices.push(i);
 }
 
 
 _root.createEmptyMovieClip("square",0);
 this.setMask(_root.square);
 function drawSquare(x,y){
  with(_root.square){
   //clear();
   moveTo(x,y);
   beginFill(0xff0000);
   lineTo(x+10,y);
   lineTo(x+10,y+10);
   lineTo(x,y+10);
   lineTo(x,y);
   endFill();
  }
 
 }
}
onClipEvent(enterFrame){
   if(currSquare       for(i=0;i    j= random(choices.length);
    t=choices[j];
    choices[j]=choices[choices.length-1];
    choices.pop();
    x=t % numX;
    y=Math.floor(t / numX);
    drawSquare(x*10,y*10);
     
    }
    currSquare+=numPerFrame;
    this._alpha=currSquare/(numX*numY)*100;
   }
 
}

/*onClipEvent(mouseMove){
  drawSquare();
  updateAfterEvent();
 }
  
*/