Flash as making snow animation effect

Source: Internet
Author: User

Use pure flash ActionScript to achieve the snow animation effect.

Effect Demo:

Click here to download the source file (Decompression password: www.webjx.com)

The way to do this is to put the following code directly into the 1th frame of the newly created flash document:

function Addmasker ()
{
_root.createemptymovieclip ("Masker",-2);
With (Masker)
{
LineStyle (1, 13421772, 100);
Beginfill (0, 100);
MoveTo (Sidediswidth, sidedisheight);
LineTo (Sidediswidth + scenewidth, sidedisheight);
LineTo (Sidediswidth + scenewidth, sidedisheight + sceneheight);
LineTo (sidediswidth, sidedisheight + sceneheight);
Endfill ();
}//End of With
Createsnow ();
}//End of the function
function Createsnow ()
{
var _l1 = 0;
while (_l1 < snownum)
{
var _l2 = Snowspace.createemptymovieclip ("s" + _L1, _L1);
var _l3 = Math.random () * 3;
Drawsnow (_L2, _L3);
_l1++;
}//End While
}//End of the function
function Drawsnow (snow, radius)
{
var p = radius * 0.900000;
With (Snow)
{
colors = [13421772, 16777215];
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:1.570796};
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 ();
}//End of With
Snowproperty (Snow, scenewidth, sceneheight);
}//End of the function
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 * 3.141593/180);
Snow.stepy = Math.random () * 2 + 1;
SetInterval (snowfall, snow);
}//End of the function
Function snowfall (snow)
{
snow._x = snow._x + snow.stepx;
snow._y = snow._y + snow.stepy;
if (Sidediswidth > Snow._x)
{
snow._x = Sidediswidth + scenewidth;
}//End If
if (Sidediswidth + scenewidth < snow._x)
{
snow._x = Sidediswidth;
}//End If
if (Sidedisheight + sceneheight < snow._y)
{
snow._y = Sidedisheight;
}//End If
}//End of the function
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 = _root.createemptymovieclip ("Room", 1);
Addmasker ();



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.