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

雪が降る

雪を降らせる。
必要になったので調べて作った。
/**
 * Copyright sakef ( http://wonderfl.net/user/sakef )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/oIoN
 */

/*
    雪を降らせる。
    必要になったので調べて作った。
*/
package
{
    import flash.display.Sprite;
    import flash.events.Event;
    
    [SWF(width="465", height="465", backgroundColor="0x000000", frameRate="40")]
    public class Main extends Sprite
    {
        private var array:Array;
        
        public function Main()
        {
            array = [];
            for(var i:int=0; i < 100; i++) array[i] = addChild(new snow());
            
            addEventListener(Event.ENTER_FRAME, onFrame);
        }
        
        private function onFrame(e:Event):void
        {
            for(var i:int=0; i < 100; i++) (array[i] as snow).render();
        }
    }
}

import flash.display.Graphics;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.BlurFilter;

class snow extends Sprite
{
    private var i:Number;
    private var k:Number;
    private var theta:Number;
    
    public function snow()
    {
        i=Math.random() * 1 + 0.5;
        k=-Math.PI + Math.random() * 2*Math.PI;
        theta=0;
        
        graphics.beginFill(0xffffff, 1);
        graphics.drawCircle(0, 0, 3);
        graphics.endFill();
        filters=[new BlurFilter()];
        
        scaleX=scaleY=Math.random() + 0.1;
        alpha=Math.random() + 0.1;
        
        x = -10 + Math.random() * 465;
        y = -10 + Math.random() * 465;
    }
    
    public function render():void
    {
        theta+=(k / 180) * Math.PI;
        x-=Math.cos(theta);
        y+=i;
        
        if (y >= 465) y=-5;
        if ((x >= 465) || (x <= 0))
        {
            x = -10 + Math.random() * 465;
            y = -5;
        }
    }
}