.

Page 4

this._x = Math.random() * 400;
this._y = Math.random() * 10 - 10;
Get random starting position.
var speed = Math.random() * 5 + 2
Get random falling speed between 2 and 7.
var Xspeed = (Math.random() * 2) * _root.dir
The xspeed varies between 0 and 2, and its direction depends on the "dir" variable.
If dir is positive the speed will be positive, if it's negative the speed will always be negative and if its 0 the speed will always be 0.
this.onEnterFrame = function()
{
        var myPoint = new Object();
        myPoint.x = this._x;
        myPoint.y = this._y;
New Point object with this Movie Clips coordinates.
if (_root.hitBitmap.hitTest(_root.hitPoint, 0, myPoint))
        {
This is a "hitTest" function of a bitmapData, it has these parameters:
hitTest(point to hit, alpha, point to check if hits);
We got the first point object on the first frame from the "hitBitmap", the alpha makes the function ignore hits on pixels with alpha below what we send to the function, but because we used 0 all pixels on the bitmap will be considered. The last point object is the coordinate that you are checking if hits.
var drawMatrix:Matrix = new Matrix ();
Create a Matrix object to draw the snow in the place it hit the accumulated snow.
drawMatrix.translate(this._x, this._y);
If we draw the snow without this line of code the snow would be draw at (0, 0), but that's not where we want it to be draw.
We want it to draw in the current _x and _y so we tell that to the Matrix object using the function "translate".
translate(_x, _y);
_root.hitBitmap.draw(this, drawMatrix);
_root.visibleBitmap.draw (this, drawMatrix);
Draw this Movie Clip in the "hitBitmap" and "visibleBitmap" using the "drawMatrix" that determinates where it needs to be draw.
Parameters for the draw function:
draw(object to be draw, matrix object);
The second parameter is optional, but then the snow would be draw at (0, 0) and that's not what we want here.
 this.removeMovieClip();
}
Remove this Movie Clip because we already have it draw.
this._y += speed;
Move the Movie Clip down.
this._x += Xspeed;
Move the Movie Clip in the _x coordinate.
        if (this._y > 500)
        {
                this.removeMovieClip();
        }
}
If the Movie Clip is out of the screen, remove it.




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