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

Particleをぐーるぐる

Get Adobe Flash player
by Nyarineko 01 Oct 2009

    Talk

    Nyarineko at 01 Oct 2009 07:21
    ず〜っと見てるとおもしろいかも、縦の動きも入れてみようかな

    Tags

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

package{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BlendMode;
    import flash.filters.BlurFilter;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    import flash.geom.ColorTransform;
    import flash.geom.Rectangle;
    import flash.geom.Point;
    
	[SWF(width = "465", height = "465", backgroundColor = "0", fps = "30")] 
	
    public class Main extends Sprite {
        private const N:uint = 20000;
        private const W:uint = 465;
        private const H:uint = 465;
        private const W1_2:uint = uint(W / 2);
        private const H1_2:uint = uint(H / 2);
        private const RECT:Rectangle = new Rectangle(0, 0, W, H);
        private const ZEROS:Point = new Point(0, 0);
        private var _head:Particle;
        private var _canvas:BitmapData;
        private var _buffer:BitmapData;
        private var _blurFilter:BlurFilter;
        private var _colorTransForm:ColorTransform;
        
        public function Main():void {
            Wonderfl.disable_capture();
            addChild(new Bitmap(_canvas = new BitmapData(W, H, false, 0x000000)));
            _buffer = _canvas.clone();
            _blurFilter = new BlurFilter(16, 16, 1);
            _colorTransForm = new ColorTransform(0.95, 0.95, 0.95);
            var p:Particle = _head = new Particle();
            for (var i:uint = 0; i < N; ++i){
                p = p.next = new Particle();
            }
            addEventListener(Event.ENTER_FRAME, _update);
            stage.addEventListener(MouseEvent.CLICK, _reset);
            _reset();
        }
        private function _reset(e:MouseEvent = null):void{
            var p:Particle = _head;
            var c:Number = 1;
            do {
                p.x = c;
                p.y = c;
                p.s = c % 100 * 0.1;
                p.radius = c % 2000 / 9;
                p.angle = 0;
                c ++;
            } while (p = p.next);
        }
        private function _update(e:Event):void{
            var p:Particle = _head;
            _buffer.lock();
            _buffer.fillRect(RECT, 0x000000);
            do {
                p.angle = p.angle + p.s;
                var radian:Number = p.angle * Math.PI / 180;
                p.x = 230 + p.radius * Math.cos(radian);
                p.y = 230 + p.radius * Math.sin(radian);
                _buffer.setPixel(p.x,p.y, 0x00AAFF);
            } while (p = p.next);
            _buffer.unlock();
            _canvas.lock();
            _canvas.colorTransform(RECT, _colorTransForm);
            _canvas.applyFilter(_canvas, RECT, ZEROS, _blurFilter);
            _canvas.draw(_buffer, null, null, BlendMode.ADD);
            _canvas.unlock();
        }
    }}
       internal class Particle {
       public var radius:Number;
       public var angle:Number;
       public var x:Number;
       public var y:Number;
       public var s:Number;
       public var next:Particle;
}