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

Onomatopoeia Planet forked from: Saqoosha challenge for professionals

/**
 * Copyright k3lab ( http://wonderfl.net/user/k3lab )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/hbYu
 */

// forked from checkmate's Saqoosha challenge for professionals
package 
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.geom.Matrix;
    [SWF(width="465", height="465", frameRate="60")] 
    public class Main extends Sprite {
        private var canvas:BitmapData;
        private var clones:BitmapData
        private var reset:Array=[]
        private var particle_Array:Array = []
        private var particle_Num:int = 1000; 
        private var sun:Sprite
        private var tmp:BitmapData
        public function Main():void {
            if (stage) init();
            else addEventListener(Event.ADDED_TO_STAGE, init);
        }
        private function init(e:Event = null):void {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            createParticle()
            setting()
            addEventListener(Event.ENTER_FRAME, update);
        }
        private function createParticle():void {
            for (var i:int = 0; i < particle_Num; i++) {
                particle_Array.push(new Patricle(Math.random() * 465, Math.random() * 465))
                var r:Number = i / particle_Num * 2 * Math.PI;
                var resetPos:Object = { x: Math.cos(r ) * 100 + 240, y:Math.sin(r ) * 100 + 240 }; 
                reset[i]=resetPos; 
            }
        }
        private function setting():void {
            canvas = new BitmapData(465, 465, false, 0);
            addChild(new Bitmap(canvas)) as Bitmap;
            sun= addChild(new Sprite()) as Sprite;
            sun.graphics.beginFill(0x0,0)
            sun.graphics.drawCircle(0, 0, 100);
            sun.graphics.endFill();
            sun.x = 240,
            sun.y = 240;
            clones = canvas.clone();
            var tf:TextField = new TextField();
            var fmt:TextFormat = new TextFormat('Verdana', 10, 0xffffff, true);
            tf.defaultTextFormat = fmt;
            tf.autoSize = TextFieldAutoSize.LEFT;
            tf.text = 'ワラ';
            tmp = new BitmapData(tf.width, tf.height, true, 0x0);
            tmp.draw(tf);
        }
        private function update(e:Event):void {
            canvas.lock();
            canvas.draw(clones);
            for (var i:int = 0; i < particle_Num; i++) {
                var p:Patricle=particle_Array[i]
                var r:Number = Math.PI * p.r / 180
                var posX:Number = Math.cos(r) * p.n * sun.mouseX / 100;
                var posY:Number = Math.sin(r) * p.n * sun.mouseY / 100;
                p.x += posX;
                p.y += posY;
                p.n += 0.09;
                p.s += 10
                if (p.x > 465 || p.x < 0 || p.y > 465 || p.y < 0) {
                    p.x = reset[i].x
                    p.y = reset[i].y
                    p.n = 0;
                    p.s= 1+Math.random()*4
                }
                canvas.copyPixels(tmp,new Rectangle(0,0,p.s,p.s),new Point(p.x,p.y))
            }
            canvas.unlock();
        }
    }
}
class Patricle {
    public var n:Number
    public var s:Number
    public var r:int
    public var x:Number;
    public var y:Number;
    public function Patricle(x:Number,y:Number) {
        r = Math.random() * 360
        n = 0;
        s = 10;
        this.x = x;
        this.y = y;
    }	
}