.

Page 3

Code Explanation

import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
Import the BitmapData, Rectangle and Point classes.
var visibleBitmap = new BitmapData(550, 400, true, 0x00FFFF00);
Create new BitmapData with the parameters:
BitmapData(width, height, transparent, background);
The object we created has 550x400, transparency, and "0x00FFFF00" as background.
_root.createEmptyMovieClip("snow", _root.getNextHighestDepth());
Create a new Movie Clip to attach the bitmap we created above. This Movie Clip with the bitmap will show all accumulated snow.
snow.attachBitmap(visibleBitmap, 33);
Attach the bitmap object into the snow Movie Clip.
var hitBitmap = new BitmapData(550, 400, true, 0x00ffffff);
Create new Bitmap to keep the limits for the falling snow.
hitBitmap.draw(limit);
Draw the limit Movie Clip inside the hitBitmap Movie Clip.
var hitPoint = new Point(hitBitmap.rectangle.x, hitBitmap.rectangle.y);
This point object will have all coordinates where we have a snow to hit on, so we will use it later to make our snow accumulate.
Point(rectangle.x, rectangle.y)
We use the rectangle property of the hitBitmap because it has all the coordinates for the snow, but we need to convert it to a Point object because later we have a "hitTest" function that will require a point.
var dir = Math.round(Math.random() * 2) - 1;
Get random direction for the snow; positive goes right, negative goes left and 0 doesn't make the snow move in the _x coordinate.
i = 0
"i" is just a variable for new Movie Clips.
setInterval(dropSnow, 50);
Call function "dropSnow" every 50 milliseconds. So we will drop a new snow every 50 milliseconds.
function dropSnow ()
{
        i++;
Increase i by one.
 _root.attachMovie("snow", "snow" + i, i);
}
Attach a new snow Movie Clip.
import flash.display.BitmapData;
import flash.geom.Matrix;
Import Bitmap class to draw the snow when it hits the floor and the Matrix class to determinate where to draw.




snow effect. Posted on 07/31/2008

Couldnt get it to work even when I copied your code. Obviously I am missing some information. The instructions were not clear enough for me and could not get it to work.



 
featured componentsfeatured components