Happy Christmas!
Made something similar for work. hope you enjoy! Merry Christmas.... happy holidays.... winter etc.
/**
* Copyright neofatalist ( http://wonderfl.net/user/neofatalist )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/mABH
*/
package {
import flash.display.Sprite;
import flash.events.*;
import flash.utils.Timer;
import flash.display.Bitmap;
import flash.display.BitmapData;
[SWF(backgroundColor=0x000000, width = '465', height = '465', frameRate = '45')]
public class Main extends Sprite {
internal var emitTime:int = 1;
internal var emitter:Timer = new Timer(emitTime);
internal var flakes:Array;
internal var snowLayer:Sprite;
public function Main() {
addChild(new Bitmap(new BitmapData(stage.stageWidth, stage.stageHeight, false, 0x660000))); // why doest the background color work? oh well.
addEventListener(Event.ADDED_TO_STAGE, init);
addEventListener(Event.REMOVED_FROM_STAGE, dispose)
}
internal function init(e:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, init);
emitter.start();
emitter.addEventListener(TimerEvent.TIMER, emit)
flakes = new Array();
snowLayer = new Sprite();
addChild(snowLayer)
}
internal function emit(e:TimerEvent):void{
if(numChildren-1 < 400){
var i:Number = flakes.length;
snowLayer.addChild(flakes[i] = new particle())
flakes[i].x = -100 + Math.floor(Math.random()*1000);
flakes[i].z = (Math.random() * 900 )+ 550;
flakes[i].y = -700;
flakes[i].addEventListener("melted", shovel);
flakes[i]._id=i;
}
}
internal function shovel(e:Event):void{
e.target.removeEventListener("melted", shovel);
snowLayer.removeChild(Sprite(e.target));
for(var i:Number =0; i<flakes.length; i++){
if(flakes[i]._id == e.target._id) flakes = flakes.filter(scrape)
}
}
internal function scrape(e:*, index:int, arr:Array):Boolean{
return (e.onStage == true);
}
internal function dispose(e:Event):void{
for(var i:Number = 0; i< flakes.length; i++) removeChild(flakes[i])
flakes= null;
removeEventListener(Event.REMOVED_FROM_STAGE, dispose)
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.*;
import flash.geom.Matrix;
import flash.display.GradientType;
class particle extends Sprite{
internal var rect:Sprite = new Sprite();
internal var onStage:Boolean = false;
internal var xVel:Number = (Math.random()*2)-1;
internal var yVel:Number= 2.5;
internal var zVel:Number = Math.random()*5 - 2.6;
internal var fil:BlurFilter = new BlurFilter();
internal var _id:Number;
public function particle() {
addEventListener(Event.ADDED_TO_STAGE, added);
addEventListener(Event.REMOVED_FROM_STAGE, dispose);
}
internal function added(e:Event):void{
var mat:Matrix= new Matrix();
var colors:Array = [0xEEEEEE,0xFFFFFF];
var alphas:Array = [1,0];
var circRad:Number = 10;
var ratios:Array = [0,255];
mat.createGradientBox(2*circRad, 2*circRad, 0, -circRad, -circRad);
graphics.lineStyle();
graphics.beginGradientFill(GradientType.RADIAL,colors,alphas,ratios,mat);
graphics.drawCircle(0,0,circRad);
graphics.endFill();
addEventListener(Event.ENTER_FRAME, loop)
onStage=true;
cacheAsBitmap = true;
}
internal function loop(e:Event):void{
if(y < 650){
y+=(yVel +(z/900));
x+=xVel;
z+=zVel;
yVel+= .01;
xVel += (Math.random()*1)-.5;
zVel += (Math.random()*1) - .5;
if( y < -800 || x < -500 || x > 1800 || z > 2000 || z < -2000 ){dispatchEvent(new Event("melted"))};
}else{
alpha -= .02;
if(scaleX < 2) scaleX += .04;
if(scaleY > .25)scaleY -= .02;
if(alpha < 0) {dispatchEvent(new Event("melted"))};
}
}
internal function dispose(e:Event):void{
fil = null;
onStage=false;
removeEventListener(Event.ENTER_FRAME, loop)
removeEventListener(Event.ADDED_TO_STAGE, added);
removeEventListener(Event.REMOVED_FROM_STAGE, dispose);
}
}