永发信息网

求flash代码

答案:2  悬赏:0  手机版
解决时间 2021-04-21 01:14
  • 提问者网友:我没有何以琛的痴心不悔
  • 2021-04-20 15:05
下雪的代码
最佳答案
  • 五星知识达人网友:長槍戰八方
  • 2021-04-20 15:17
onLoad = function ()
{
n = 160;
var i = 1;
while (i <= n)
{
attachMovie("snow", "snow" + i, i);
var a = Math.round(100 * Math.random() + 41);
var b = Math.round(50 * Math.random() + 51);
with (this["snow" + i])
{
_x = 550 * Math.random();
_y = 400 * Math.random();
_xscale = a;
_yscale = a;
_alpha = b;
_rotation = a;
this["snow" + i].x = Math.cos(3.141593E+000 * Math.random());
this["snow" + i].y = 2 + 2 * Math.random();
} // End of with
++i;
} // end while
};
onEnterFrame = function ()
{
var i = 1;
while (i <= n)
{
with (this["snow" + i])
{
_x = _x + x;
_y = _y + y;
_rotation = _rotation + y;
if (_y > 400)
{
_y = 0;
}
else if (_x > 550)
{
_x = 0;
}
else if (_x < 0)
{
_x = 550;
} // end else if
} // End of with
++i;
} // end while
};
全部回答
  • 1楼网友:你可爱的野爹
  • 2021-04-20 15:44

fallSnow(this, 150, [550, 400]); //150改变这个值可以设置下雪的大小,[550,400]设置在影片中下雪的范围是宽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 = 5; //改变5这个值可以设置从顶部开始落下的位置 } }

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯