In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: 雪が降る

雪を降らせる。
必要になったので調べて作った。
Get Adobe Flash player
by hacker_lu4lwrz2 25 Aug 2010
/**
 * Copyright hacker_lu4lwrz2 ( http://wonderfl.net/user/hacker_lu4lwrz2 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/cdfX
 */

// forked from sakef's 雪が降る
/*
    雪を降らせる。
    必要になったので調べて作った。
*/

package
{
    import flash.display.Sprite;
    import net.hires.debug.Stats;

    [SWF(width="465", height="465", backgroundColor="0x000022", frameRate="30")]
    public class snows extends Sprite
    {
        public function snows()
        {
            addChild(new Stats);
            for(var k:int=0; k < 100; k++){ 
            addChild(new snow(stage.stageWidth, stage.stageHeight))
            };
        }
    }
}

import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.*;
import flash.filters.BlurFilter;
import flash.utils.*;

class snow extends Sprite
{
    private var timer:Timer;
    private var i:Number;
    private var k:Number;
    private var theta:Number;
    private var movieHeight:Number;
    private var movieWidth:Number;
    public var weight:Number;
    public var window:Number = 20;

    public function snow(w:Number, h:Number)
    {
        movieHeight=h;
        movieWidth=w;

        i=Math.random() * 1 + 0.5;
        k=-Math.PI + Math.random() * Math.PI;
        theta=0;

        graphics.beginFill(0xffffff, 1);
        graphics.drawCircle(2, 2, 3);
        graphics.endFill();
        //filters=[new BlurFilter()];

        scaleX=scaleY=Math.random() + 0.2;
        weight = scaleY;
        alpha=Math.random() + 0.1;

        x = -10 + Math.random() * movieWidth;
        y = -10 + Math.random() * movieHeight;

        addEventListener(Event.ENTER_FRAME, onFrame);
        
        timer = new Timer(1000, 0);
        timer.addEventListener(TimerEvent.TIMER, resetFunc);
        timer.start();
    }

    private function onFrame(e:Event):void
    {
        theta+=(k / 180) * Math.PI;
        x-=Math.cos(theta) * window;
        y+=i*weight*100*(-0.1);

        if (y <= -5)//movieHeight)
            y = movieHeight;
        if ((x >= movieWidth) || (x <= 0))
        {
            x = -10 + Math.random() * movieWidth;
            y = -5;
        }
    }
    private function resetFunc(e:Event):void {
            
            window = Math.ceil(Math.random()*50);
            //forceMap.perlinNoise( 14, 14, 3, seed, false, true, 1|2|0|0, false, offset );
            //offset[0].x += 1.5;
            //offset[1].y += 1.0;
            timer = new Timer(1000, 0);
        timer.addEventListener(TimerEvent.TIMER, resetFunc);
        timer.start();
    }
}