#72003/8/11 17:14:08
offsetX = 275;
offsetY = 100;
left = 0;
right = 0;
top = 0;
leftGoal = 0;
rightGoal = 0;
topGoal = 0;
rate = .2;
decay = .9;
shapes = ["15|30", "10|50", "5|70", "0|100"];
for (var i = 0; i var name = "flame"+i;
createEmptyMovieClip(name, i);
_root[name]._x = offsetX;
_root[name]._y = offsetY;
_root[name].offset = parseInt(shapes[i].split("|")[0]);
_root[name].fade = parseInt(shapes[i].split("|")[1]);
}
createEmptyMovieClip("heat", i);
heat._x = offsetX;
heat._y = offsetY;
checkEdge = function (cur, side, dist) {
change = 0;
if (cur>side) {
change -= Math.random()*dist;
} else if (cur<-side) {
change += Math.random()*dist;
}
return change;
};
onEnterFrame = function () {
// change edge goals
leftGoal += Math.random()*6-3;
leftGoal += checkEdge(leftGoal, 10, 3);
rightGoal += Math.random()*6-3;
rightGoal += checkEdge(rightGoal, 10, 3);
topGoal += Math.random()*8-4;
topGoal += checkEdge(topGoal, 15, 4);
leftAccel = (leftGoal-left)*rate;
leftVeloc += leftAccel;
leftVeloc *= decay;
left += leftVeloc;
rightAccel = (rightGoal-right)*rate;
rightVeloc += rightAccel;
rightVeloc *= decay;
right += rightVeloc;
topAccel = (topGoal-top)*rate;
topVeloc += topAccel;
topVeloc *= decay;
top += topVeloc;
// make flames
for (var i = 0; i with (_root["flame"+i]) {
clear();
colors = [0xFCE39C, 0xF4AC35];
alphas = [_root["flame"+i].fade, _root["flame"+i].fade-20];
ratios = [70, 255];
matrix = {matrixType:"box", x:-50, y:50, w:100, h:200, r:0};
beginGradientFill("radial", colors, alphas, ratios, matrix);
lineStyle(1, 0x000000, 0);
moveTo(0-left+right, 0-top-_root["flame"+i].offset*2);
curveTo(40+_root["flame"+i].offset+right, 180, 0, 200);
curveTo(-40-_root["flame"+i].offset-left, 180, 0-left+right, 0-top-_root["flame"+i].offset*2);
endFill();
}
}
// adjust heat
with (_root.heat) {
clear();
colors = [0x986932, 0x986932];
alphas = [70, 0];
ratios = [20, 255];
matrix = {matrixType:"box", x:-20-left/2, y:120-top, w:40+right/2, h:120+top, r:0};
beginGradientFill("radial", colors, alphas, ratios, matrix);
lineStyle(1, 0x000000, 0);
moveTo(-50, 0);
lineTo(50, 0);
lineTo(50, 200);
lineTo(-50, 200);
lineTo(-50, 0);
endFill();
}
duplicateMovieClip(_root["flame"+(shapes.length-1)], "shapeMask", shapes.length+1);
heat.setMask(shapeMask);
};
说明:不是我写的。感谢作者。
编辑历史:[这消息被zqazy编辑过(编辑时间2003-08-11 17:18:19)]