• 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

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稚 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.


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





No.1 Web Design
Studio | Advertisement | About Webzo | Contact Webzo | Terms of Use | Free Video Tutorials by Helpivds

Copyright © 2007 NR Concepts Ltd. All rights reserved.