※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


FORKED
  1. // forked from soundkitchen's キラメキのようななにか
  2. package
  3. {
  4.     import flash.display.Bitmap;
  5.     import flash.display.BitmapData;
  6.     import flash.display.BlendMode;
  7.     import flash.display.Graphics;
  8.     import flash.display.Shape;
  9.     import flash.display.Sprite;
  10.     import flash.events.Event;
  11.     import flash.events.MouseEvent;
  12.     import flash.filters.BitmapFilter;
  13.     import flash.filters.BitmapFilterQuality;
  14.     import flash.filters.BlurFilter;
  15.     import flash.geom.Point;
  16.     [SWF(frameRate=60, width=500, height=500, backgroundColor=0x000000)]
  17.     public class Main extends Sprite
  18.     {
  19.         private static var _zero:Point = new Point();
  20.         private var _canvas:Shape;
  21.         private var _film:BitmapData;
  22.         private var _filter:BitmapFilter;
  23.         private var _mouseDownFlag:Boolean;
  24.         private var _particles:Array;
  25.         public function Main()
  26.         {
  27.             addEventListener(Event.ADDED_TO_STAGE, initialize);
  28.         }
  29.         private function initialize(evt:Event):void
  30.         {
  31.             removeEventListener(evt.type, arguments.callee);
  32.             Particle.initialize(stage);
  33.             _particles = [];
  34.             _mouseDownFlag = false;
  35.             _canvas = new Shape();
  36.             _filter = new BlurFilter(66, BitmapFilterQuality.MEDIUM);
  37.             _film = new BitmapData(stage.stageWidth, stage.stageHeight, true0);
  38.             addChild(new Bitmap(_film));
  39.             addEventListener(Event.ENTER_FRAME, step);
  40.             stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
  41.             stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
  42.         }
  43.         private function step(evt:Event):void
  44.         {
  45.             var i:int,
  46.                 g:Graphics,
  47.                 p:Particle;
  48.             if (_mouseDownFlag)
  49.             {
  50.                 for (i=0; i<10; i++)
  51.                 {
  52.                     addParticle();
  53.                 }
  54.             }
  55.             g = _canvas.graphics;
  56.             g.clear();
  57.             for each (p in _particles)
  58.             {
  59.                 p.update();
  60.                 g.beginFill(p.color);
  61.                 g.drawCircle(p.x, p.y, 1);
  62.                 g.endFill();
  63.                 if (!p.isAlive)
  64.                 {
  65.                     i = _particles.indexOf(p);
  66.                     _particles.splice(i, 1);
  67.                 }
  68.             }
  69.             _film.lock();
  70.             _film.applyFilter(_film, _film.rect, _zero, _filter);
  71.             _film.draw(_canvas, nullnull, BlendMode.ADD);
  72.             _film.unlock();
  73.         }
  74.         private function mouseDownHandler(evt:MouseEvent):void
  75.         {
  76.             _mouseDownFlag = true;
  77.         }
  78.         private function mouseUpHandler(evt:MouseEvent):void
  79.         {
  80.             _mouseDownFlag = false;
  81.         }
  82.         private function addParticle():void
  83.         {
  84.             var i:int,
  85.                 len:Number,
  86.                 angle:Number;
  87.             len = Math.random() * 5;
  88.             angle = Math.random() * Math.PI * 2;
  89.             _particles.push(new Particle(mouseX, mouseY, len, angle));
  90.         }
  91.     }
  92. }
  93. import flash.display.Stage;
  94. import flash.geom.Rectangle;
  95. class Particle
  96. {
  97.     private static var _frameRate:Number;
  98.     private static var _stageRect:Rectangle;
  99.     private var _x:Number;
  100.     private var _y:Number;
  101.     private var _tick:uint;
  102.     private var _len:Number;
  103.     private var _angle:Number;
  104.     private var _energy:Number;
  105.     public static function initialize(stage:Stage):void
  106.     {
  107.         _frameRate = stage.frameRate;
  108.         _stageRect = new Rectangle(00, stage.stageWidth, stage.stageHeight);
  109.     }
  110.     public function get x():Number
  111.     {
  112.         return _x;
  113.     }
  114.     public function get y():Number
  115.     {
  116.         return _y;
  117.     }
  118.     public function get color():uint
  119.     {
  120.         return (_energy * 0xFD) << 16|(_energy * 0xFE) << 8|(_energy * 0xAE);
  121.     }
  122.     public function get isAlive():Boolean
  123.     {
  124.         return _stageRect.contains(x, y);
  125.     }
  126.     function Particle(x:Number, y:Number, len:Number, angle:Number)
  127.     {
  128.         _x = x;
  129.         _y = y;
  130.         _len = len;
  131.         _angle = angle;
  132.         _tick = 0;
  133.         _energy = 1;
  134.     }
  135.     public function update():void
  136.     {
  137.         _energy *= .98;
  138.         _x += _len * Math.cos(_angle);
  139.         _y += 9.8 * (++_tick / _frameRate) + _len * Math.sin(_angle);
  140.     }
  141. }
noswf
Get Adobe Flash Player