- Flash↔归类
-
代码制作的随机遮罩
时间:2019-4-20 21:23:58 作者:佚名 来源:原创 浏览:21 评论:0内容摘要: 制作方法如下:1、导入一张图至库2、将图拖到场景,对齐,选中图,转换为影片剪辑元件3、选中影片剪辑,打开动作面板,输入如下语句onClipEvent(load){numY=40;numX=55;numPerFrame=24;currSquare=0;choices=new Ar...制作方法如下:
1、导入一张图至库
2、将图拖到场景,对齐,选中图,转换为影片剪辑元件
3、选中影片剪辑,打开动作面板,输入如下语句
onClipEvent(load){
numY=40;
numX=55;
numPerFrame=24;
currSquare=0;
choices=new Array();
for (i=0;i<numY*numX;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<numY*numX){
for(i=0;i<numPerFrame;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();
}
*/
- 相关评论
- 友情链接
-
文章管理系统 |