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

flash on 2011-7-3

Copyright clockmaker ( http://wonderfl.net/user/clockmaker )
MIT License ( http://www.opensource.org/licenses/mit-license.php )
Downloaded from: http://wonderfl.net/c/1Qdd
Get Adobe Flash player
by tomonobu 03 Jul 2011
/**
 * Copyright tomonobu ( http://wonderfl.net/user/tomonobu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/wY1n
 */


package {
    import flash.display.*;
    import flash.events.*;
    public class Main extends Sprite {
        public function Main() {
            // BitmapDataの初期化
            var bmd:BitmapData = new BitmapData(465, 465, false, 0x0);
            var bmp:Bitmap = new Bitmap(bmd);
            addChild(bmp);
            
            // パーティクルの作成
            var particles:Array = [];
            for(var i:int=0; i<1000; i++){
                var p:Particle = new Particle();
                //p.x = 550 / 2; // 画面中央の座標を指定
                //p.y = 440 / 2; 
                p.theta = Math.random() * 360;
                p.radius = (200 - i/5);
                p.x = p.radius * Math.cos(p.theta * Math.PI / 180) + (465 / 2); // 画面中央の座標を指定
                p.y = p.radius * Math.sin(p.theta * Math.PI / 180) + (465 / 2);
                //p.vx = Math.cos(100 * Math.PI / 180);  // ランダムな速度を指定
                //p.vy = Math.sin(100 * Math.PI / 180);
                p.color = i%2 ? 0x00aeef :0xec008c; // 白色を指定
                particles[i] = p;
            }
            
            // アニメーション処理
            addEventListener(Event.ENTER_FRAME, enterFrameHandler);
            
            function enterFrameHandler(e:Event):void{
                // リセット (画面を黒く塗りつぶす)
                bmd.lock();
                bmd.fillRect(bmd.rect, 0x000000);
                for(var i:int=0; i<particles.length; i++){
                    var p:Particle = particles[i];
                    // 速度を座標に適用
                    p.theta = p.theta + 3;
                    p.radius = (p.radius >= 0) ? p.radius - 2:0;
                    p.x = p.radius * Math.cos((p.theta) * Math.PI / 180) + (465 / 2);
                    p.y = p.radius * Math.sin((p.theta) * Math.PI / 180) + (465 / 2);
                    // 描画処理
                    bmd.setPixel(p.x, p.y, p.color);
                }
                bmd.unlock();
            }
            
        }
    }
}

/** パーティクルクラス */
class Particle {
    public var x:Number; // X座標
    public var y:Number; // Y座標
    public var vx:Number; // X軸方向の速さ
    public var vy:Number; // Y軸方向の速さ
    public var theta:Number; // 角度
    public var radius:Number;
    public var color:uint; // 色情報
}