Programming
Ideas:
When the main scene is loaded, a certain number of snowflakes are randomly distributed on the screen, after each frame play, these snowflakes will be in the x axis and the y direction of the random displacement, so as a whole to produce snow effect.
Steps:
1. Open Flash MX 2004, new document, document size 550*400 pixel, frame frequency set to 25FPS.
2. Draw a snowflake on the stage with a line tool, select the snowflake, press F8 to convert it to a movie clip, and delete the main scene snowflake movie clip.
3. Press Ctrl+l to open the library, select the Snowflake movie clip in the library, right-click, select "link" in the pop-up menu, and in the Next Pop-up Link Properties window, set the identifier to snow, and tick before "Export for action script" and "Export in first frame".
4. Back to the main scene, select Layer 1 frame 1th, press F9 to open the Action Script editing window, enter the following code:
This.onload = function () {
n = 60;
var i = 1;
while (n >= i) {
This.attachmovie ("Snow", "snow" + I, I);
var a = Math.Round (Math.random * () + 41);
var B = Math.Round (Math.random () + 51);
With (this["snow" + i]) {
_x = Math.random * ();
_y = * Math.random ();
_xscale = A;
_yscale = A;
_alpha = b;
_rotation =a;
this["Snow" + i].x = Math.Cos (Math.PI * math.random ());//The increment of displacement after each frame of the snowflake along the x axis
this["Snow" + I].y = 2*math.random (); The increment of the displacement after each frame of the snowflake along the y axis
}
i++;
}
}
This.onload ();
This.onenterframe = function () {
var a = 1;
while (n>= a) {
With (this["snow" + A]) {
_x = x;
_y = y;
_rotation = y;
if (_y > 400) {
_y = 0;
}else if (_x>550) {
_x=0;
}else if (_x<0) {
_x=550;
}
}
a++;
}
}
5. Press Ctrl+enter to test the film, the effect is as follows:
http://www.flash8.net/bbs/UploadFile/2005-6/2005619134418354.swf
Note: The while loop is used here, and of course it is available in the For loop.