Flash production to achieve the "snow drift" effect

Source: Internet
Author: User
Tags continue prepare

First look at the effect:

Click here to download the source file

  Production steps:

First, prepare the original. Total 3 originals

Original 1: The shape of the snowflake. That is, casually draw a white circle instead.
Original 2: The action of snowflakes. This MC holds the action of snowflakes falling. Do it with a guide line. How do snowflakes float, see how you draw the guide line.
Original 3: Snowflake generator. This MC controls the production of snowflakes.

Start with the structure of the original 2. Take a look at the screenshot below:

You can see that. The snow "float" This action is to use the guide line to achieve. Because you can not just do a movement trajectory of the drift way, because it looks too rigid, so we set up a few more guide lines, and then more than a few different snowflakes "float" method.
The script frame is the 1th frame, the 4th frame, and the frame where each guide line ends.
1th Hardwood:

Timer=random (50)
gotoAndPlay (3)

4th Hardwood:

if (timer==0)
{VAR mov;
mov= "mov" Add random (2)
gotoAndPlay (MOV)
Return
}
timer--
gotoAndPlay (3)

Through the two frames of the script can be seen.

The timer variable here is a time buffer variable. That is, because the existence of this variable, snowflakes will not start to float, but wait for this variable value of 0 will be through the guide line to show the floating movement.

The judgment in the 4th frame is to judge whether the timer variable value is 0, if it is, randomly jump to the back of a few anchors. That is, jump to the beginning of a certain "drifting" action.

The last two sentences are to keep the timer down. Then return to the previous frame. Continue to play, and then reduce .... Of course, this is also done when the timer is not 0.

"Floating" Action end frame:

gotoAndStop (2)

Return to the first frame, continue to buffer. Prepare for the next "float" action.

And then the original 3:

Original 3 The thing to do is to load just the snow that has the "floating" action. First frame:

snow_num=120//defines the number of snowflakes
ran_scale=150//defines the size random amount of snowflakes
angle=30//defines the amount of random rotation of snowflakes
for (n=1;n<=snow_num;n++)//"Generate Snowflake" Custom function based on number of snowflakes
{Createsnow ("Snow" +n,n)
}
function Createsnow (sn,n) {
var scale
Attachmovie ("Snow", sn,n)//from the library to load snowflakes, that is, original 2
This[sn]._x=random (600) -50//defines some of its properties
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 hardwood:

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 is to be done in this frame, is to determine whether those snowflakes are moving to the 2nd frame. The code in the original 2 can be seen. When the snowflakes are gone, they will stop in the 2nd frame. So, here, when the snowflake stops in the 2nd frame, we first delete it, then use the "Create snowflake" 's custom function to recreate it. This process is actually randomly changing the next time the snowflake position, angle, size and other attributes to achieve a random, vivid effect.

Finally, put the original 3 into the main scene, test the movie ...

In fact, the original 3 is the whole snow scene. If you put the original 3 of the frame directly into the main scene, that is to let the main scene "Snow".



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.