Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
some simple snowflake code
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.Event;
var PARTICLES:Number = 60;
var OPACITY_SPEED:Number = 20;
var snowFlakes:Array = new Array();
var snowFlakesProps:Array = new Array();
var STAGE_WIDTH:Number = 400;
var STAGE_HEIGHT:Number = 600;
addEventListener(Event.ENTER_FRAME, function(event:Event) {
for(var f = 0; f < snowFlakes.length; f++) {
var t = snowFlakes[f];
var o = snowFlakesProps[f];
if(t.y > 0) {
t.alpha -= .01;
}
if(t.y > STAGE_HEIGHT) {
t.y = -10;
t.alpha = 1;
} else {
t.y += o.sp;
}
}
});
for(var i = 0; i < PARTICLES; i++) {
var s = new Snow();
s.name = 'flake_' + i;
s.x = Math.random() * STAGE_WIDTH;
s.y -= Math.random() * STAGE_HEIGHT;
var o:Object = new Object();
o.sp = 1+Math.random()*2;
o.wi = -1.5+Math.random()*(1.4*3);
snowFlakesProps[i] = o;
addChild(s);
snowFlakes.push(s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment