怎么让这个“下雪flash“在规定的帧停下? 10
fallSnow(this,100,[550,400]);functionfallSnow(path,num,size){for(vari=0;i<num;i++){pa...
fallSnow(this, 100, [550, 400]);
function fallSnow(path, num, size) {
for (var i = 0; i<num; i++) {
path.createEmptyMovieClip("s"+i, i);
var mc = path["s"+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);
}
var loop = function () {
updateAfterEvent();
for (var i = 0; i<num; i++) {
var mc = path["s"+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);
}
};
var interval = setInterval(loop, 10);
}
function createSnow(mc, radius, c, alpha) {
with (mc) {
moveTo(0, -radius);
beginFill(c, alpha);
lineStyle(0, "0x000000", 0);
for (var i = 1; i<=6; i++) {
var a1 = -Math.PI/6+i*Math.PI/3;
var a2 = 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();
}
}
function scanTar(mc) {
if (mc.startTime>=mc.xtime) {
mc.startTime = 0;
mc.xtime = random(20);
mc.ro = [1, -1][random(2)];
}
}
function scanEdge(mc, size) {
if (mc._x>size[0]) {
mc._x = 0;
} else if (mc._x<0) {
mc._x = size[0];
}
if (mc._y>size[1]) {
mc._y = 0;
}
} 展开
function fallSnow(path, num, size) {
for (var i = 0; i<num; i++) {
path.createEmptyMovieClip("s"+i, i);
var mc = path["s"+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);
}
var loop = function () {
updateAfterEvent();
for (var i = 0; i<num; i++) {
var mc = path["s"+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);
}
};
var interval = setInterval(loop, 10);
}
function createSnow(mc, radius, c, alpha) {
with (mc) {
moveTo(0, -radius);
beginFill(c, alpha);
lineStyle(0, "0x000000", 0);
for (var i = 1; i<=6; i++) {
var a1 = -Math.PI/6+i*Math.PI/3;
var a2 = 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();
}
}
function scanTar(mc) {
if (mc.startTime>=mc.xtime) {
mc.startTime = 0;
mc.xtime = random(20);
mc.ro = [1, -1][random(2)];
}
}
function scanEdge(mc, size) {
if (mc._x>size[0]) {
mc._x = 0;
} else if (mc._x<0) {
mc._x = size[0];
}
if (mc._y>size[1]) {
mc._y = 0;
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询