flash as简单制作飘雪动画
网站建设 2021-07-03 14:34www.dzhlxh.cn网站建设
不用任何元件,只用一帧,在flash8中就可以做出雪景画面。设背景为黑色,或导入一张你喜欢的图片做背景,复制狼蚁网站SEO优化的代码到场景的第一帧就行了。
fallSnow(this,150,[600,375]);
functionfallSnow(path,num,size){
for(vari=0;i<num;i ){
path.createEmptyMovieClip("xue" i,i);
varmc=path["xue" i];
mc._x=random(size[0]);
mc._y=random(size[1]);
mc.ro=[1,-1][random(2)];
mc.xtime=random(20);
mc.startTime=0;
mc.id=Math.pow(i,1/2);
createSnow(mc,mc.id/2.5,"0xffffff",20*mc.id);
}
varloop=function(){
updateAfterEvent();
for(vari=0;i<num;i ){
varmc=path["xue" i];
mc._rotation =mc.ro*5;
mc._x =mc.id*mc.ro/10;
mc._y =mc.id/2;
mc.startTime ;
scanTar(mc);
scanEdge(mc,size);
}
};
varinterval=setInterval(loop,10);
}
functioncreateSnow(mc,radius,c,alpha){
with(mc){
moveTo(0,-radius);
beginFill(c,alpha);
linestyle(0,"0x000000",0);
for(vari=1;i<=6;i ){
vara1=-Math.PI/6 i*Math.PI/3;
vara2=i*Math.PI/3;
lineTo((radius/5)*Math.sin(a1),-(radius/5)*Math.cos(a1));
lineTo(radius*Math.sin(a2),-radius*Math.cos(a2));
}
endFill();
}
}
functionscanTar(mc){
if(mc.startTime>=mc.xtime){
mc.startTime=0;
mc.xtime=random(20);
mc.ro=[1,-1][random(2)];
}
}
functionscanEdge(mc,size){
if(mc._x>size[0]){
mc._x=0;
}elseif(mc._x<0){
mc._x=size[0];
}
if(mc._y>size[1]){
mc._y=0;
}
}
functionfallSnow(path,num,size){
for(vari=0;i<num;i ){
path.createEmptyMovieClip("xue" i,i);
varmc=path["xue" i];
mc._x=random(size[0]);
mc._y=random(size[1]);
mc.ro=[1,-1][random(2)];
mc.xtime=random(20);
mc.startTime=0;
mc.id=Math.pow(i,1/2);
createSnow(mc,mc.id/2.5,"0xffffff",20*mc.id);
}
varloop=function(){
updateAfterEvent();
for(vari=0;i<num;i ){
varmc=path["xue" i];
mc._rotation =mc.ro*5;
mc._x =mc.id*mc.ro/10;
mc._y =mc.id/2;
mc.startTime ;
scanTar(mc);
scanEdge(mc,size);
}
};
varinterval=setInterval(loop,10);
}
functioncreateSnow(mc,radius,c,alpha){
with(mc){
moveTo(0,-radius);
beginFill(c,alpha);
linestyle(0,"0x000000",0);
for(vari=1;i<=6;i ){
vara1=-Math.PI/6 i*Math.PI/3;
vara2=i*Math.PI/3;
lineTo((radius/5)*Math.sin(a1),-(radius/5)*Math.cos(a1));
lineTo(radius*Math.sin(a2),-radius*Math.cos(a2));
}
endFill();
}
}
functionscanTar(mc){
if(mc.startTime>=mc.xtime){
mc.startTime=0;
mc.xtime=random(20);
mc.ro=[1,-1][random(2)];
}
}
functionscanEdge(mc,size){
if(mc._x>size[0]){
mc._x=0;
}elseif(mc._x<0){
mc._x=size[0];
}
if(mc._y>size[1]){
mc._y=0;
}
}
上一篇:Flash AS 教程:交互动画
下一篇:Flash as3.0教程:弹性小球