Another way for Flash to make snowflakes

Source: Internet
Author: User
Tags eval

Solving ideas

The main idea is to make a lot of snowflakes by copying a snowflake film clip, of course there is a limit to it. Otherwise the CPU will not stand it. Then by setting the location coordinates of the copied snowflakes, the snow effect is achieved.

Specific steps

1, run Flash MX, set the document properties to 500*400. Draws the background of a gradient fill in layer 1.

2, create a new movie clip, named "Snowflake". Draw a simple snowflake shape in the editing area. Size is about 11*11 pixels. As shown in Figure 1.

3, go back to the main scene, drag the movie clip "Snowflake" into the scene, and name it "Snow" in the property panel.

4, select the movie clip, open the as panel, and add the following statement:

Onclipevent (enterframe) {//Every play one frame on the following as
This._x + = Math.random () * (This._xscale)/10;
This._y + = Math.random () * (This._yscale)/10;//let snowflakes in the X, Y axis of the upward movement, each move distance of 1/10 of their own size, in order to enhance the random effect, we use the math.random () to better control.
if (this._x>500) {
this._x = 0;
//When snowflakes drift out of the main scene, return to the left side of the main scene.
if (this._y>400) {
this._y = 0;
///When snowflakes drift out of the main scene, return to the top of the main scene.
}

5, create a new layer, add as in frame 1th

i = 1;
while (i<=200) {
Duplicatemovieclip ("Snow", "Snow" +i, I);
SetProperty ("Snow" +i, _x, Random (500));
SetProperty ("Snow" +i, _y, Random (400));
SetProperty ("Snow" +i, _xscale, Math.random () *60+40);
SetProperty ("Snow" +i, _yscale, eval ("Snow" +i). _xscale);
SetProperty ("Snow" +i, _alpha, eval ("Snow" +i). _xscale+random (30));
i++;
}

Copy 200 snowflake MC, and randomly placed in a position, and the size of snowflakes is also randomly generated, and the transparency of snowflakes by the size of the snow (X, Y axis ratio) to decide, the greater the transparency of the snowflakes higher, smaller snowflakes more transparent. This effect is close to the snow to see clearly, and the distant snowflakes a little fuzzy ... More lifelike ...



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.