效果没有理想中的好。
纯粹利用 as 实现,这样一来,因为全部由CPU计算,使得 CPU 使用率巨高,甚至高达 100%(偶的 CPU 是 AMD Athlon 2500+)
fscommand("fullscreen", true);
function createmc(i) {
x = Math.random()*1024;
y = Math.random()*768;
x1 = Math.random()*40;
x2 = Math.random()*40;
x3 = Math.random()*40;
x4 = Math.random()*40;
y1 = Math.random()*40;
y2 = Math.random()*40;
y3 = Math.random()*40;
y4 = Math.random()*40;
color = Math.random()*0xFFFFFF;
alpha = Math.random()*100;
_root.createEmptyMovieClip("fd_mc"+i, i+10);
with (eval("fd_mc"+i)) {
lineStyle(1, color, alpha);
beginFill(color, alpha);
moveTo(x1+x, y1+y);
lineTo(x2+x, y2+y);
lineTo(x3+x, y3+y);
lineTo(x4+x, y4+y);
lineTo(x1+x, y1+y);
endFill();
}
//end with;
}
//end function createmc();
function mc() {
for (i=0; i<200; i++) {
createmc(i);
eval("fd_mc"+i).onEnterFrame = function() {
alpha = Math.random();
if (alpha>0.5) {
mcalpha = alpha*10;
} else {
mcalpha = (alpha-1)*10;
}
//end if;
this._alpha += mcalpha;
};
//end function;
}
//end for;
}
//end function;
mc();
setInterval(mc, 3000);
源代码如下:
fscommand(“fullscreen”, true);
function createmc(i) {
x = Math.random()*1024;
y = Math.random()*768;
x1 = Math.random()*40;
x2 = Math.random()*40;
x3 = Math.random()*40;
x4 = Math.random()*40;
y1 = Math.random()*40;
y2 = Math.random()*40;
y3 = Math.random()*40;
y4 = Math.random()*40;
color = Math.random()*0xFFFFFF;
alpha = Math.random()*100;
_root.createEmptyMovieClip(“fd_mc”+i, i+10);
with (eval(“fd_mc”+i)) {
lineStyle(1, color, alpha);
beginFill(color, alpha);
moveTo(x1+x, y1+y);
lineTo(x2+x, y2+y);
lineTo(x3+x, y3+y);
lineTo(x4+x, y4+y);
lineTo(x1+x, y1+y);
endFill();
}
//end with;
}
//end function createmc();
function mc() {
for (i=0; i<200; i++) {
createmc(i);
eval(“fd_mc”+i).onEnterFrame = function() {
alpha = Math.random();
if (alpha>0.5) {
mcalpha = alpha*10;
} else {
mcalpha = (alpha-1)*10;
}
//end if;
this._alpha += mcalpha;
};
//end function;
}
//end for;
}
//end function;
mc();
setInterval(mc, 3000);