网页雪花特效代码(html雪花特效代码源码)
求网页制作雪花飘落效果的代码
下面是雪花飘落的js代码
拷进去就好了,或者调用!!!!
script language="JavaScript"
!--
N =20;
Y = new Array();
X = new Array();
S = new Array();
A = new Array();
B = new Array();
M = new Array();
V = (document.layers)?1:0;
iH=(document.layers)?window.innerHeight:window.document.body.clientHeight;
iW=(document.layers)?window.innerWidth:window.document.body.clientWidth;
for (i=0; i N; i++){
Y[i]=Math.round(Math.random()*iH);
X[i]=Math.round(Math.random()*iW);
S[i]=Math.round(Math.random()*5+2);
A[i]=0;
B[i]=Math.random()*0.1+0.1;
M[i]=Math.round(Math.random()*1+7);
}
if (V){
for (i = 0; i N; i++)
{document.write("LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,"+M[i]+","+M[i]+"';z-index: 1font color=white size=3 face='Wingdings'T/font/LAYER")}
}
else{
document.write('div style="position:absolute;top:0px;left:0px;z-index: 1"');
document.write('div style="position:relative;z-index: 1"');
for (i = 0; i N; i++)
{document.write('div id="si" style="position:absolute;z-index: 1;top:0;left:0;width:'+M[i]+';height:'+M[i]+';font-size:'+M[i]+'"font color=white size=3 face="Wingdings"T/font/div')}
document.write('/div/div');
}
function snow(){
var H=(document.layers)?window.innerHeight:window.document.body.clientHeight;
var W=(document.layers)?window.innerWidth:window.document.body.clientWidth;
var T=(document.layers)?window.pageYOffset:document.body.scrollTop;
var L=(document.layers)?window.pageXOffset:document.body.scrollLeft;
for (i=0; i N; i++){
sy=S[i];
sx=S[i]*Math.cos(A[i]);
Y[i]+=sy;
X[i]+=sx;
if (Y[i] H){
Y[i]=-10;
X[i]=Math.round(Math.random()*W);
M[i]=Math.round(Math.random()*1+7);
S[i]=Math.round(Math.random()*5+2);
}
if (V){document.layers['sn'+i].left=X[i];document.layers['sn'+i].top=Y[i]+T}
else{si[i].style.pixelLeft=X[i];si[i].style.pixelTop=Y[i]+T}
A[i]+=B[i];
}
setTimeout('snow()',40);
}
snow()
//--
/script
flash中雪花场景的制作代码是什么?
第一步:先创建一个雪花的影片剪辑(雪花飘下来的剪辑,在插入→新建元件里面可以创建)将 其拖动到场景中,在属性面板中命名为aa;
第二步:新建一个图层命名为动作,插入三个空白关键帧,第一个帧的代码是 i=1 ;第二个帧的代码是:
duplicateMovieClip("aa", i, i);
setProperty(i, _x, random(1000)+50);
setProperty(i, _y, random(600));
setProperty(i, _alpha, random(10)+40);
tint = random(40)+40;
eval(i)._xscale = tint;
eval(i)._yscale = tint;
i = i+1;
if (i == 400) {
gotoAndPlay(1);
}
第三个帧的代码是:
gotoAndPlay(2);
然后就可以了!试试看 那里不清楚再问我!
求FLASH雪花代码
var sceneWidth =550;//定义场景的宽
var sceneHeight=400;//定义场景的高
var sideDisWidth = Stage.width/2-sceneWidth/2;//定义变量,雪花的横向位移范围
var sideDisHeight = Stage.height/2-sceneHeight/2;//定义变量,雪花的纵向位移范围
var snowNum = 150;//定义雪花的数量
var snowSpace:MovieClip = _root.createEmptyMovieClip("room", 1);//声明一个空影片剪辑snowSpace.
function addMasker() {//声明addMasker函数,执行两项工作.1是画外边框,2是画雪花景
_root.createEmptyMovieClip("masker", -2);//创建空影片剪辑masker,层深-2.任务是为舞台画外边框,并填充颜色
with (masker) {//设置masker的属性。
lineStyle(1, 0xcccccc, 100);//设置线条颜色
beginFill(0x000000, 0);//绘制矩形闭合路径,并填充灰色,透明度为0.
moveTo(sideDisWidth, sideDisHeight);//绘制起点
lineTo(sideDisWidth+sceneWidth, sideDisHeight);//绘制的右上角点的位置
lineTo(sideDisWidth+sceneWidth, sideDisHeight+sceneHeight);//绘制的右下角点的位置
lineTo(sideDisWidth, sideDisHeight+sceneHeight);//绘制的左下角点的位置
lineTo(sideDisWidth, sideDisHeight);//绘制的左上角点的位置
endFill();//结束绘制
}
createSnow();
}
function createSnow() {//定义一个匿名函数,完成声明一个雪花MC,雪花半径,循环画雪花
var n = 0;//局部变量n=0
while (nsnowNum) {//在0到150数量范围循环画雪花
var snow:MovieClip = snowSpace.createEmptyMovieClip("s"+n, n);//声明snowSpace剪辑由"s"+n个snow组成
var radius:Number = Math.random()*3;//定义雪花半径大小
drawSnow(snow, radius);//把snow, radius把参数传递给drawSnow函数
n++;
}
}
function drawSnow(snow:MovieClip, radius:Number) {//定义一个匿名函数,画一个雪花
var p = radius*.9;//局部变量P,用来定义雪花大小的坐标值
with (snow) {//设置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);// 设置填充色.
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);//把参数传递给snowProperty
}
function snowProperty(snow, w, h) {//定义一个匿名函数,一个雪花如何下降
snow._x = sideDisWidth+Math.random()*w;//根据可编辑的宽及0和1中的任意一个数乘雪花宽计算雪花的X轴起始位置
snow._y = sideDisHeight+Math.random()*h;//根据可编辑的高及0和1中的任意一个数乘雪花高计算雪花的Y轴起始位置
snow._rotation = Math.random()*120+30;//设置旋转角度.有立体感.雪花的旋转程度为0和1中的任意一个数乘120+30
snow.stepX = Math.cos((snow._rotation*Math.PI)/180);//雪花横向位移.用计算余弦(旋转角度*常数3.14)/180)
snow.stepY = Math.random()*2+1;//雪花纵向位移.为0和1中的任意一个数*2-1
setInterval(snowFall, 30, snow); //每隔0.5秒调用一次,由snowFall完成
}
function snowFall(snow) {//定义一个匿名函数,该函数为大雪花降落位移范围
snow._x += snow.stepX;//横向下落位移
snow._y += snow.stepY;//纵向下落位移
if (snow._xsideDisWidth) {//如果横向位移不超出sideDisWidth值
snow._x = sideDisWidth+sceneWidth;//为雪花的横坐标附值
}
if (snow._xsideDisWidth+sceneWidth) { //如果雪花的横向坐标大于所附的值
snow._x = sideDisWidth; //横向位移再回到初始点
}
if (snow._ysideDisHeight+sceneHeight) {//如果雪花的纵向坐标大于所附的值
snow._y = sideDisHeight;//纵向位移再回到初始点
}
}
addMasker();
求网页飘雪花源代码
把下列代码加到网页的Body/Body标签之间
head
title:::飘雪花效果:::网页特效代码:::失落网家园;/title
/head
BODY bgcolor="#000000"
SCRIPT language=JavaScript1.2
var snowsrc="img/snow.gif"
var no = 10;
var ns4up = (document.layers) ? 1 : 0; // browser sniffer
var ie4up = (document.all) ? 1 : 0;
var dx, xp, yp; // coordinate and position variables
var am, stx, sty; // amplitude and step variables
var i, doc_width = 800, doc_height =600;
if (ns4up) {
doc_width = self.innerWidth;
doc_height = self.innerHeight;
} else if (ie4up) {
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx = new Array();
xp = new Array();
yp = new Array();
am = new Array();
stx = new Array();
sty = new Array();
for (i = 0; i no; ++ i) {
dx[i] = 0; // set coordinate variables
xp[i] = Math.random()*(doc_width-50); // set position variables
yp[i] = Math.random()*doc_height;
am[i] = Math.random()*20; // set amplitude variables
stx[i] = 0.02 + Math.random()/10; // set step variables
sty[i] = 0.7 + Math.random(); // set step variables
if (ns4up) { // set layers
if (i == 0) {
document.write("layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"a href=\"\"img src='"+snowsrc+"' border=\"0\"/a/layer");
} else {
document.write("layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"img src='"+snowsrc+"' border=\"0\"/layer");
}
} else if (ie4up) {
if (i == 0) {
document.write("div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"a href=\"\"img src='"+snowsrc+"' border=\"0\"/a/div");
} else {
document.write("div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"img src='"+snowsrc+"' border=\"0\"/div");
}
}
}
function snowNS() { // Netscape main animation function
for (i = 0; i no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = self.innerWidth;
doc_height = self.innerHeight;
}
dx[i] += stx[i];
document.layers["dot"+i].top = yp[i];
document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowNS()", 10);
}
function snowIE() { // IE main animation function
for (i = 0; i no; ++ i) { // iterate for every dot
yp[i] += sty[i];
if (yp[i] doc_height-50) {
xp[i] = Math.random()*(doc_width-am[i]-30);
yp[i] = 0;
stx[i] = 0.02 + Math.random()/10;
sty[i] = 0.7 + Math.random();
doc_width = document.body.clientWidth;
doc_height = document.body.clientHeight;
}
dx[i] += stx[i];
document.all["dot"+i].style.pixelTop = yp[i];
document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);
}
setTimeout("snowIE()", 10);
}
if (ns4up) {
snowNS();
} else if (ie4up) {
snowIE();
}
/SCRIPT
table border="0" width="100%" cellpadding="0"
tr
td width="100%"font color="#ffffff" size="2"b飘雪花效果/b注意保存这个图片(img border="1" src="img/snow.gif" width="16" height="17")/font/td
/tr
tr
td width="100%"
/table
script language="JavaScript" type="text/javascript" src="js.js"/scripttr/body
/html
请教网页飘雪的插景,布满整个页面(不是背景)怎么制作
点击编辑窗口左下角的“HTML”选项卡,即出现源代码窗口,将特效代码粘贴进去即可。
这里有代码~