当前位置:软件学习 > Flash >>

flash雪花飘啊飘(纯AS)

insert into filecontent(title,content,filesendtime,filesendid,siteindex,systype,isown,z_type) value('雪花飘啊飘','

///////////////////////////////////////////////////////////////////////////
// 照着turbine前辈的早先的一个文件做的,他的用到了类,
// 本想也用类来写,无奈as2的类暂时用不熟,mx的类又不想再用,
// 所以只好凑合凑合,拼个效果出来先,里面好多代码看上去乱糟糟的
// 呵呵,先就这样了,看来得抓紧学习类的使用,呼呼呼呼
// 没做任何注释,对不起大家了\\\"\\\",谁帮忙注释下,注释的好的加分哦\\\"\\\"嘎嘎...
// 源代码就不帖了,反正把这些代码全复制就可以了
// 运行环境flashMX2004
///////////////////////////////////////////////////////////////////////

var sceneWidth = sceneHeight=300;
var sideDisWidth = Stage.width/2-sceneWidth/2;
var sideDisHeight = Stage.height/2-sceneHeight/2;
var snowNum = 80;
var snowSpace:MovieClip = _root.createEmptyMovieClip("room", 1);
function addMasker() {
_root.createEmptyMovieClip("masker", 10000);
with (masker) {
beginFill(0x000550, 100);
moveTo(sideDisWidth, sideDisHeight);
lineTo(sideDisWidth+sceneWidth, sideDisHeight);
lineTo(sideDisWidth+sceneWidth, sideDisHeight+sceneHeight);
lineTo(sideDisWidth, sideDisHeight+sceneHeight);
lineTo(sideDisWidth, sideDisHeight);
endFill();
}
snowSpace.setMask(masker);
createSnow();
}
function snowProperty(snow, w, h) {
snow._x = sideDisWidth+Math.random()*w;
snow._y = sideDisHeight+Math.random()*h;
snow._rotation = Math.random()*120+30;
snow.stepX = Math.cos((snow._rotation*Math.PI)/180);
snow.stepY = Math.random()*2+1;
setInterval(snowFall, 30, snow);
}
function drawSnow(snow:MovieClip, radius:Number) {
var p = radius*.9;
with (snow) {
colors = [0xCCCCCC, 0xFFFFFF];
alphas = [100, 100];
ratios = [0, 255];
matrix = {matrixType:"box", x:-Math.random()*2*radius, y:-Math.random()*2*radius, w:2*radius, h:2*radius, r\\\"\\\"90/180)*Math.PI};
beginGradientFill("radial", colors, alphas, ratios, matrix);
moveTo(0, -radius);
curveTo(p, -p, radius, 0);
curveTo(p, p, 0, radius);
curveTo(-p, p, -radius, 0);
curveTo(-p, -p, 0, -radius);
endFill();
}
snowProperty(snow, sceneWidth, sceneHeight);
}
function createSnow() {
var n = 0;
while (n<snowNum) {
var snow:MovieClip = snowSpace.createEmptyMovieClip("s"+n, n);
var radius:Number = Math.random()*3;
drawSnow(snow, radius);
n++;
}
}
function snowFall(snow) {
snow._x += snow.stepX;
snow._y += snow.stepY;
if (snow._x<sideDisWidth) {
snow._x = sideDisWidth+sceneWidth;
}
if (snow._x>sideDisWidth+sceneWidth) {
snow._x = sideDisWidth;
}
if (snow._y>sideDisHeight+sceneHeight) {
snow._y = sideDisHeight;
}
}
addMasker();
_root.createEmptyMovieClip("myMC", 10);
with (myMC) {
lineStyle(1, 0xcccccc, 100);
moveTo(sideDisWidth, sideDisHeight);
lineTo(sideDisWidth+sceneWidth, sideDisHeight);
lineTo(sideDisWidth+sceneWidth, sideDisHeight+sceneHeight);
lineTo(sideDisWidth, sideDisHeight+sceneHeight);
lineTo(sideDisWidth, sideDisHeight);
var infor:TextField = myMC.createTextField("infor", 1, sideDisWidth+sceneWidth-100, sideDisHeight+sceneHeight, 100, 20);
infor.autoSize="right";
infor.selectable=false;
infor.textColor = 0xcccccc;
infor.text = "by holybozo";
}
_root.createEmptyMovieClip("bg", -1);
with (bg) {
beginFill(0x999999, 100);
moveTo(0, 0);
lineTo(Stage.width, 0);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 0);
endFill();
}

下载地址:http://space.flash8.net/bbs/attachment.php?aid=295814

补充:flash教程,Action
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,