• Home
  • Free Tutorials
  • Free Video Tutorials

Adobe Photoshop
Autodesk 3ds Max
CSS
Flash
Help Center Live
iPhone
Joomla
Make Money Online!
Mambo
mIRC
Outlook Express
SEO / SEM
Simple Machine Forum
Target Explorer

Accumulative Snow Effect

Category : Flash Views : 31531
Version : 8 Rating : 
3.3/5 (53 votes)
  • Currently 3.30/5
  • 1
  • 2
  • 3
  • 4
  • 5
Type : Text Source File: accumulative-snow-effect.zip
Result: See the result


Previous | 1 | 2 | 3 | 4 | Next

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 its 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 Clip痴 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痴 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痴 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.


More cool tech articles from other blogs.

Place your ad here
Loading...


Previous | 1 | 2 | 3 | 4 | Next
How to Video Tutorials on software by Helpvids.com

Sponsors





Studio | Advertisement | About Webzo | Contact Webzo | Terms of Use | Free Video Tutorials by Helpivds

Copyright © 2007 NR Concepts Ltd. All rights reserved.