Flash as makes beautiful snowflake effect

Source: Internet
Author: User
Tags prepare

Why is it "Cainiao?
That's because Cainiao may be able to take a look.
First, prepare the original. There are 3 in total
Original 1: snowflake shape, that is, to draw a white circle instead.
Original 2: Snowflake action. This MC stores the action of snowflake falling. Use the guiding line to do it. How does the snowflake float? It depends on how you draw the guiding line.
Original 3: snowflake generator. This MC controls the generation of snowflake.
Starting from the structure of the original 2.

We can see that. the snowflake "float" is implemented through the guide line. because it cannot be just a moving track drifting method, because it looks too rigid, so we have to set up a few more boot lines, then there are several different snowflake "floating" method.
Scripts are the 1st rows. 4th rows, and the one that ends with each guide line.
1st labels:

Timer = random (50)
Gotoandplay (3)


4th labels:

If (timer = 0)
{Var mov;
Mov = "mov" add random (2)
Gotoandplay (mov)
Return
}
Timer --
Gotoandplay (3)


The two slave scripts show that.
The TIMER variable here is a time buffer variable. that is to say, because of the existence of this variable, the snowflake will not start to float as soon as it comes out, but will only show the float action through the guide line when the value of this variable is 0.
In 4th, the TIMER variable value is determined to be 0. If yes, it is randomly jumped to the next few anchors, that is, to the beginning of a "floating" action.
The following two sentences are used to reduce the number of TIMER instances and then return to the previous screenshot. Then play the video again, and then reduce the number... of course, this is also executed when the value of TIMER is not 0.
"Floating" action ends:

Gotoandstop (2)


That is, the first response is returned. Continue buffering. Prepare for the next "floating" action.

The first thing to do in article 3 is to load the snowflake with the "floating" action.
First region:

Snow_num = 120 // defines the number of snowflakes
Ran_scale = 150 // defines the random size of snowflake
Angle = 30 // defines the random rotation of snow.
For (n = 1; n <= snow_num; n ++) // execute the "generate snowflake" custom function based on the number of snowflakes.
{CreateSnow ("snow" + n, n)
}
Function CreateSnow (sn, n ){
Var scale
AttachMovie ("snow", sn, n) // load snow from the database, that is, original 2
This [sn]. _ x = random (600)-50 // define some of its attributes
This [sn]. _ y =-10
Scale = 50 + random (ran_scale)
This [sn]. _ xscale = scale
This [sn]. _ yscale = scale
This [sn]. _ rotation =-random (angle)
This [sn]. _ alpha = 50 + random (80)
}

5th labels:

Var sn
For (n = 1; n <= snow_num; n ++)
{
Sn = "snow" + n
If (getProperty (sn, _ currentframe) = 2 ){
RemoveMovieClip (sn)
CreateSnow (sn, n )}}
Gotoandplay (2)


What we need to do in this notebook is to determine if those snowflakes have been moved to the 2nd million RMB. it can be seen from the code in original 2. when the snow float, it will stop at 2nd Tib. so here, when the Snowflake stops at the 10th percentile, we should first delete it, and then re-create it with the "create snowflake" custom function. this process is actually randomly changing the next position, angle, size, and other attributes of the snowflake to achieve a random and vivid effect.
Finally, put the original 3 in the home scene and test the film...
In fact, the original 3 is the entire snowy scene. If you put the original 3 scene directly on the home scene, that is, let the main scene "snow.
The principle is really simple. Cainiao will do it.
Here is the original program

 

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.