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

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

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


forked from : checkmate's Saqoosha challenge for professionals [diff(230)]

FAVORITE BY
:
:
:
パーティクルテキスト破裂
:
:
ペイントボールみたい
:
火サスを連想
:
普通のテキストが現れたと思ったら、かっこよく炸裂
FORKED
  1. // forked from soundkitchen's パァン!
  2. package
  3. {
  4.     import flash.display.BlendMode;
  5.     import flash.display.Bitmap;
  6.     import flash.display.BitmapData;
  7.     import flash.display.Sprite;
  8.     import flash.events.Event;
  9.     import flash.events.TimerEvent;
  10.     import flash.text.TextField;
  11.     import flash.text.TextFieldAutoSize;
  12.     import flash.text.TextFormat;
  13.     import flash.filters.BitmapFilterQuality;
  14.     import flash.filters.BlurFilter;
  15.     import flash.geom.Point;
  16.     import flash.utils.Timer;
  17.     import com.flashdynamix.utils.SWFProfiler;
  18.     import frocessing.color.ColorHSV;
  19.     import org.libspark.betweenas3.BetweenAS3;
  20.     import org.libspark.betweenas3.easing.*;
  21.     import org.libspark.betweenas3.tweens.ITween;
  22.     [SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
  23.     public class Main extends Sprite
  24.     {
  25.         private static var P_ZERO:Point = new Point();
  26.         private static var F_BLUR:BlurFilter = new BlurFilter(44, BitmapFilterQuality.LOW);
  27.         private var _txt:TextField;
  28.         private var _hsv:ColorHSV;
  29.         private var _film:BitmapData;
  30.         private var _timer:Timer;
  31.         private var _activeParticles:Vector.<Particle>;
  32.         private var _inactiveParticles:Vector.<Particle>;
  33.         public function Main()
  34.         {
  35.             addEventListener(Event.ADDED_TO_STAGE, initialize);
  36.         }
  37.         private function initialize(evt:Event):void
  38.         {
  39.             removeEventListener(Event.ADDED_TO_STAGE, initialize);
  40.             SWFProfiler.init(this);
  41.             var i:uint,
  42.                 fmt:TextFormat,
  43.                 bm:Bitmap;
  44.             _activeParticles = new Vector.<Particle>();
  45.             _inactiveParticles = new Vector.<Particle>();
  46.             for (i=0; i<10000; i++)
  47.             {
  48.                 _inactiveParticles.push(new Particle());
  49.             }
  50.             _hsv = new ColorHSV(0111);
  51.             fmt = new TextFormat();
  52.             fmt.font = "Verdana";
  53.             fmt.bold = true;
  54.             fmt.size = 36;
  55.             _txt = new TextField();
  56.             _txt.defaultTextFormat = fmt;
  57.             _txt.autoSize = TextFieldAutoSize.LEFT;
  58.             _txt.text = "パァン!";
  59.             _film = new BitmapData(stage.stageWidth, stage.stageHeight, true0);
  60.             bm = new Bitmap(_film);
  61.             //bm.blendMode = BlendMode.ADD;
  62.             addChild(bm);
  63.             _timer = new Timer(0);
  64.             _timer.addEventListener(TimerEvent.TIMER, timerHandler);
  65.             _timer.start();
  66.             addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  67.         }
  68.         private function enterFrameHandler(evt:Event):void
  69.         {
  70.             var i:uint,
  71.                 p:Particle;
  72.             _hsv.h = ++_hsv.h % 360;
  73.             _film.lock();
  74.             _film.applyFilter(_film, _film.rect, P_ZERO, F_BLUR);
  75.             for (i=0; i<_activeParticles.length; i++)
  76.             {
  77.                 p = _activeParticles[i];
  78.                 p.x += p.vx;
  79.                 p.y += p.vy;
  80.                 p.life--;
  81.                 _film.setPixel32(p.x, p.y, p.color);
  82.                 if (!p.life)
  83.                 {
  84.                     _activeParticles.splice(i, 1);
  85.                     _inactiveParticles.push(p);
  86.                     i--;
  87.                 }
  88.             }
  89.             _film.unlock();
  90.         }
  91.         private function timerHandler(evt:TimerEvent):void
  92.         {
  93.             _timer.delay = (50 + Math.random() * 950) >> 0;
  94.             var sp:Sprite,
  95.                 bm:Bitmap,
  96.                 bmd:BitmapData,
  97.                 t:ITween;
  98.             //_hsv.h = ++_hsv.h % 360;
  99.             _txt.textColor = _hsv.value;
  100.             bmd = new BitmapData(_txt.width, _txt.height, true0);
  101.             bmd.draw(_txt);
  102.             bm = new Bitmap(bmd);
  103.             bm.smoothing = true;
  104.             bm.x -= bm.width >> 1;
  105.             bm.y -= bm.height >> 1;
  106.             sp = new Sprite();
  107.             sp.addChild(bm);
  108.             sp.x = (Math.random() * stage.stageWidth) >> 0;
  109.             sp.y = (Math.random() * stage.stageHeight) >> 0;
  110.             sp.scaleX = 0;
  111.             sp.scaleY = 0;
  112.             sp.rotation = (Math.random() * 360) >> 0;
  113.             //sp.blendMode = BlendMode.ADD;
  114.             addChild(sp);
  115.             t = BetweenAS3.serial(
  116.                 BetweenAS3.to(sp, {
  117.                     'scaleX'1,
  118.                     'scaleY'1,
  119.                     'rotation'0
  120.                 }, 2, Expo.easeIn),
  121.                 BetweenAS3.removeFromParent(sp)
  122.             );
  123.             t.onComplete = tweenComplete;
  124.             t.onCompleteParams = [sp, bm, bmd];
  125.             t.play();
  126.         }
  127.         private function tweenComplete(sp:Sprite, bm:Bitmap, bmd:BitmapData):void
  128.         {
  129.             var i:uint, j:uint, c:uint,
  130.                 cx:Number, cy:Number,
  131.                 angle:Number, strength:Number,
  132.                 p:Particle;
  133.             cx = sp.x + bm.x;
  134.             cy = sp.y + bm.y;
  135.             for (i=0; i<bmd.width; i++)
  136.             {
  137.                 for (j=0; j<bmd.height; j++)
  138.                 {
  139.                     c = bmd.getPixel32(i, j);
  140.                     if (!c) continue;
  141.                     p = _inactiveParticles.length ? _inactiveParticles.shift() : new Particle();
  142.                     angle = Math.random() * Math.PI * 2;
  143.                     strength = Math.random() * 20;
  144.                     p.vx = Math.cos(angle) * strength;
  145.                     p.vy = Math.sin(angle) * strength;
  146.                     p.x = cx + i;
  147.                     p.y = cy + j;
  148.                     p.color = c;
  149.                     p.life = 200;
  150.                     _activeParticles.push(p);
  151.                 }
  152.             }
  153.             bmd.dispose();
  154.         }
  155.     }
  156. }
  157. class Particle
  158. {
  159.     public var vx:Number;
  160.     public var vy:Number;
  161.     public var x:Number;
  162.     public var y:Number;
  163.     public var color:uint;
  164.     public var life:uint;
  165. }
noswf
  1. // forked from soundkitchen's パァン!
  2. package
  3. {
  4.     import flash.display.BlendMode;
  5.     import flash.display.Bitmap;
  6.     import flash.display.BitmapData;
  7.     import flash.display.Sprite;
  8.     import flash.events.Event;
  9.     import flash.events.TimerEvent;
  10.     import flash.text.TextField;
  11.     import flash.text.TextFieldAutoSize;
  12.     import flash.text.TextFormat;
  13.     import flash.filters.BitmapFilterQuality;
  14.     import flash.filters.BlurFilter;
  15.     import flash.geom.Point;
  16.     import flash.utils.Timer;
  17.     import com.flashdynamix.utils.SWFProfiler;
  18.     import frocessing.color.ColorHSV;
  19.     import org.libspark.betweenas3.BetweenAS3;
  20.     import org.libspark.betweenas3.easing.*;
  21.     import org.libspark.betweenas3.tweens.ITween;
  22.     [SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
  23.     public class Main extends Sprite
  24.     {
  25.         private static var P_ZERO:Point = new Point();
  26.         private static var F_BLUR:BlurFilter = new BlurFilter(44, BitmapFilterQuality.LOW);
  27.         private var _txt:TextField;
  28.         private var _hsv:ColorHSV;
  29.         private var _film:BitmapData;
  30.         private var _timer:Timer;
  31.         private var _activeParticles:Vector.<Particle>;
  32.         private var _inactiveParticles:Vector.<Particle>;
  33.         public function Main()
  34.         {
  35.             addEventListener(Event.ADDED_TO_STAGE, initialize);
  36.         }
  37.         private function initialize(evt:Event):void
  38.         {
  39.             removeEventListener(Event.ADDED_TO_STAGE, initialize);
  40.             SWFProfiler.init(this);
  41.             var i:uint,
  42.                 fmt:TextFormat,
  43.                 bm:Bitmap;
  44.             _activeParticles = new Vector.<Particle>();
  45.             _inactiveParticles = new Vector.<Particle>();
  46.             for (i=0; i<10000; i++)
  47.             {
  48.                 _inactiveParticles.push(new Particle());
  49.             }
  50.             _hsv = new ColorHSV(0111);
  51.             fmt = new TextFormat();
  52.             fmt.font = "Verdana";
  53.             fmt.bold = true;
  54.             fmt.size = 36;
  55.             _txt = new TextField();
  56.             _txt.defaultTextFormat = fmt;
  57.             _txt.autoSize = TextFieldAutoSize.LEFT;
  58.             _txt.text = "パァン!";
  59.             _film = new BitmapData(stage.stageWidth, stage.stageHeight, true0);
  60.             bm = new Bitmap(_film);
  61.             //bm.blendMode = BlendMode.ADD;
  62.             addChild(bm);
  63.             _timer = new Timer(0);
  64.             _timer.addEventListener(TimerEvent.TIMER, timerHandler);
  65.             _timer.start();
  66.             addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  67.         }
  68.         private function enterFrameHandler(evt:Event):void
  69.         {
  70.             var i:uint,
  71.                 p:Particle;
  72.             _hsv.h = ++_hsv.h % 360;
  73.             _film.lock();
  74.             _film.applyFilter(_film, _film.rect, P_ZERO, F_BLUR);
  75.             for (i=0; i<_activeParticles.length; i++)
  76.             {
  77.                 p = _activeParticles[i];
  78.                 p.x += p.vx;
  79.                 p.y += p.vy;
  80.                 p.life--;
  81.                 _film.setPixel32(p.x, p.y, p.color);
  82.                 if (!p.life)
  83.                 {
  84.                     _activeParticles.splice(i, 1);
  85.                     _inactiveParticles.push(p);
  86.                     i--;
  87.                 }
  88.             }
  89.             _film.unlock();
  90.         }
  91.         private function timerHandler(evt:TimerEvent):void
  92.         {
  93.             _timer.delay = (50 + Math.random() * 950) >> 0;
  94.             var sp:Sprite,
  95.                 bm:Bitmap,
  96.                 bmd:BitmapData,
  97.                 t:ITween;
  98.             //_hsv.h = ++_hsv.h % 360;
  99.             _txt.textColor = _hsv.value;
  100.             bmd = new BitmapData(_txt.width, _txt.height, true0);
  101.             bmd.draw(_txt);
  102.             bm = new Bitmap(bmd);
  103.             bm.smoothing = true;
  104.             bm.x -= bm.width >> 1;
  105.             bm.y -= bm.height >> 1;
  106.             sp = new Sprite();
  107.             sp.addChild(bm);
  108.             sp.x = (Math.random() * stage.stageWidth) >> 0;
  109.             sp.y = (Math.random() * stage.stageHeight) >> 0;
  110.             sp.scaleX = 0;
  111.             sp.scaleY = 0;
  112.             sp.rotation = (Math.random() * 360) >> 0;
  113.             //sp.blendMode = BlendMode.ADD;
  114.             addChild(sp);
  115.             t = BetweenAS3.serial(
  116.                 BetweenAS3.to(sp, {
  117.                     'scaleX'1,
  118.                     'scaleY'1,
  119.                     'rotation'0
  120.                 }, 2, Expo.easeIn),
  121.                 BetweenAS3.removeFromParent(sp)
  122.             );
  123.             t.onComplete = tweenComplete;
  124.             t.onCompleteParams = [sp, bm, bmd];
  125.             t.play();
  126.         }
  127.         private function tweenComplete(sp:Sprite, bm:Bitmap, bmd:BitmapData):void
  128.         {
  129.             var i:uint, j:uint, c:uint,
  130.                 cx:Number, cy:Number,
  131.                 angle:Number, strength:Number,
  132.                 p:Particle;
  133.             cx = sp.x + bm.x;
  134.             cy = sp.y + bm.y;
  135.             for (i=0; i<bmd.width; i++)
  136.             {
  137.                 for (j=0; j<bmd.height; j++)
  138.                 {
  139.                     c = bmd.getPixel32(i, j);
  140.                     if (!c) continue;
  141.                     p = _inactiveParticles.length ? _inactiveParticles.shift() : new Particle();
  142.                     angle = Math.random() * Math.PI * 2;
  143.                     strength = Math.random() * 20;
  144.                     p.vx = Math.cos(angle) * strength;
  145.                     p.vy = Math.sin(angle) * strength;
  146.                     p.x = cx + i;
  147.                     p.y = cy + j;
  148.                     p.color = c;
  149.                     p.life = 200;
  150.                     _activeParticles.push(p);
  151.                 }
  152.             }
  153.             bmd.dispose();
  154.         }
  155.     }
  156. }
  157. class Particle
  158. {
  159.     public var vx:Number;
  160.     public var vy:Number;
  161.     public var x:Number;
  162.     public var y:Number;
  163.     public var color:uint;
  164.     public var life:uint;
  165. }
noswf
  1. // forked from soundkitchen's パァン!
  2. package
  3. {
  4.     import flash.display.BlendMode;
  5.     import flash.display.Bitmap;
  6.     import flash.display.BitmapData;
  7.     import flash.display.Sprite;
  8.     import flash.events.Event;
  9.     import flash.events.TimerEvent;
  10.     import flash.text.TextField;
  11.     import flash.text.TextFieldAutoSize;
  12.     import flash.text.TextFormat;
  13.     import flash.filters.BitmapFilterQuality;
  14.     import flash.filters.BlurFilter;
  15.     import flash.geom.Point;
  16.     import flash.geom.Matrix;
  17.     import flash.utils.Timer;
  18.     import com.flashdynamix.utils.SWFProfiler;
  19.     import frocessing.color.ColorHSV;
  20.     import org.libspark.betweenas3.BetweenAS3;
  21.     import org.libspark.betweenas3.easing.*;
  22.     import org.libspark.betweenas3.tweens.ITween;
  23.     [SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
  24.     public class Main extends Sprite
  25.     {
  26.         private static var P_ZERO:Point = new Point();
  27.         private static var F_BLUR:BlurFilter = new BlurFilter(44, BitmapFilterQuality.LOW);
  28.         private var _txt:TextField;
  29.         private var _hsv:ColorHSV;
  30.         private var _film:BitmapData;
  31.         private var _timer:Timer;
  32.         private var _activeParticles:Vector.<Particle>;
  33.         private var _inactiveParticles:Vector.<Particle>;
  34.         
  35.         private var _taiga:TaigaLoader;
  36.         public function Main()
  37.         {
  38.             addEventListener(Event.ADDED_TO_STAGE, initialize);
  39.         }
  40.         private function initialize(evt:Event):void
  41.         {
  42.             removeEventListener(Event.ADDED_TO_STAGE, initialize);
  43.             SWFProfiler.init(this);
  44.             
  45.             _taiga = new TaigaLoader();
  46.             _taiga.addEventListener( Event.COMPLETE, loadCompleteHandler );
  47.             _taiga.load();
  48.         }
  49.         private function loadCompleteHandler(e:Event) :void {
  50.             _taiga.removeEventListener( Event.COMPLETE, loadCompleteHandler );
  51.             
  52.             var i:uint,
  53.                 fmt:TextFormat,
  54.                 bm:Bitmap;
  55.             _activeParticles = new Vector.<Particle>();
  56.             _inactiveParticles = new Vector.<Particle>();
  57.             for (i=0; i<10000; i++)
  58.             {
  59.                 _inactiveParticles.push(new Particle());
  60.             }
  61.             _hsv = new ColorHSV(0111);
  62.             fmt = new TextFormat();
  63.             fmt.font = "Verdana";
  64.             fmt.bold = true;
  65.             fmt.size = 36;
  66.             _txt = new TextField();
  67.             _txt.defaultTextFormat = fmt;
  68.             _txt.autoSize = TextFieldAutoSize.LEFT;
  69.             _txt.text = "パァン!";
  70.             _film = new BitmapData(stage.stageWidth, stage.stageHeight, true0);
  71.             bm = new Bitmap(_film);
  72.             //bm.blendMode = BlendMode.ADD;
  73.             addChild(bm);
  74.             _timer = new Timer(0);
  75.             _timer.addEventListener(TimerEvent.TIMER, timerHandler);
  76.             _timer.start();
  77.             addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  78.         }
  79.         private function enterFrameHandler(evt:Event):void
  80.         {
  81.             var i:uint,
  82.                 p:Particle;
  83.             _hsv.h = ++_hsv.h % 360;
  84.             _film.lock();
  85.             _film.applyFilter(_film, _film.rect, P_ZERO, F_BLUR);
  86.             for (i=0; i<_activeParticles.length; i++)
  87.             {
  88.                 p = _activeParticles[i];
  89.                 p.x += p.vx;
  90.                 p.y += p.vy;
  91.                 p.life--;
  92.                 _film.setPixel32(p.x, p.y, p.color);
  93.                 if (!p.life)
  94.                 {
  95.                     _activeParticles.splice(i, 1);
  96.                     _inactiveParticles.push(p);
  97.                     i--;
  98.                 }
  99.             }
  100.             _film.unlock();
  101.         }
  102.         private function timerHandler(evt:TimerEvent):void
  103.         {
  104.             _timer.delay = (50 + Math.random() * 950) >> 0;
  105.             var sp:Sprite,
  106.                 bm:Bitmap,
  107.                 bmd:BitmapData,
  108.                 t:ITween;
  109.             //_hsv.h = ++_hsv.h % 360;
  110.             _txt.textColor = _hsv.value;
  111.             bmd = new BitmapData( _taiga.data.width/2, _taiga.data.height/2true0);
  112.             bmd.draw( _taiga.data, new Matrix(0.5000.5) );
  113.             bm = new Bitmap(bmd);
  114.             bm.smoothing = true;
  115.             bm.x -= bm.width >> 1;
  116.             bm.y -= bm.height >> 1;
  117.             sp = new Sprite();
  118.             sp.addChild(bm);
  119.             sp.x = (Math.random() * stage.stageWidth) >> 0;
  120.             sp.y = (Math.random() * stage.stageHeight) >> 0;
  121.             sp.scaleX = 0;
  122.             sp.scaleY = 0;
  123.             sp.rotation = (Math.random() * 360) >> 0;
  124.             //sp.blendMode = BlendMode.ADD;
  125.             addChild(sp);
  126.             t = BetweenAS3.serial(
  127.                 BetweenAS3.to(sp, {
  128.                     'scaleX'1,
  129.                     'scaleY'1,
  130.                     'rotation'0
  131.                 }, 2, Expo.easeIn),
  132.                 BetweenAS3.removeFromParent(sp)
  133.             );
  134.             t.onComplete = tweenComplete;
  135.             t.onCompleteParams = [sp, bm, bmd];
  136.             t.play();
  137.         }
  138.         private function tweenComplete(sp:Sprite, bm:Bitmap, bmd:BitmapData):void
  139.         {
  140.             var i:uint, j:uint, c:uint,
  141.                 cx:Number, cy:Number,
  142.                 angle:Number, strength:Number,
  143.                 p:Particle;
  144.             cx = sp.x + bm.x;
  145.             cy = sp.y + bm.y;
  146.             for (i=0; i<bmd.width; i++)
  147.             {
  148.                 for (j=0; j<bmd.height; j++)
  149.                 {
  150.                     c = bmd.getPixel32(i, j);
  151.                     if (!c) continue;
  152.                     p = _inactiveParticles.length ? _inactiveParticles.shift() : new Particle();
  153.                     angle = Math.random() * Math.PI * 2;
  154.                     strength = Math.random() * 20;
  155.                     p.vx = Math.cos(angle) * strength;
  156.                     p.vy = Math.sin(angle) * strength;
  157.                     p.x = cx + i;
  158.                     p.y = cy + j;
  159.                     p.color = c;
  160.                     p.life = 200;
  161.                     _activeParticles.push(p);
  162.                 }
  163.             }
  164.             bmd.dispose();
  165.         }
  166.     }
  167. }
  168. class Particle
  169. {
  170.     public var vx:Number;
  171.     public var vy:Number;
  172.     public var x:Number;
  173.     public var y:Number;
  174.     public var color:uint;
  175.     public var life:uint;
  176. }
  177. import flash.events.*;
  178. import flash.display.*;
  179. import flash.system.*;
  180. import flash.net.*;
  181. class TaigaLoader extends EventDispatcher {
  182.     public var data:BitmapData;
  183.     private var _loader:Loader;
  184.     public function TaigaLoader(){
  185.         _loader = new Loader();
  186.         _loader.contentLoaderInfo.addEventListener( Event.COMPLETE, _loaderCompleteHandler );
  187.     }
  188.     private function _loaderCompleteHandler(e:Event):void {
  189.         _loader.contentLoaderInfo.removeEventListener( Event.COMPLETE, _loaderCompleteHandler );
  190.         data = Bitmap(_loader.content ).bitmapData;
  191.         _loader = null;
  192.         dispatchEvent( new Event( Event.COMPLETE ) );
  193.     }
  194.     private var _imgSrc:String = "http://assets.wonderfl.net/images/related_images/e/e9/e9b6/e9b64ead20dd3d674e79ea186b29f974341b480f";
  195.             
  196.     public function load():void {
  197.         var url:URLRequest = new URLRequest( _imgSrc );
  198.         _loader.load( url, new LoaderContext(true) );
  199.     }
  200. }
noswf
  1. // forked from soundkitchen's パァン!
  2. package
  3. {
  4.     import flash.display.BlendMode;
  5.     import flash.display.Bitmap;
  6.     import flash.display.BitmapData;
  7.     import flash.display.Sprite;
  8.     import flash.events.Event;
  9.     import flash.events.TimerEvent;
  10.     import flash.text.TextField;
  11.     import flash.text.TextFieldAutoSize;
  12.     import flash.text.TextFormat;
  13.     import flash.filters.BitmapFilterQuality;
  14.     import flash.filters.BlurFilter;
  15.     import flash.geom.Point;
  16.     import flash.utils.Timer;
  17.     import com.flashdynamix.utils.SWFProfiler;
  18.     import frocessing.color.ColorHSV;
  19.     import org.libspark.betweenas3.BetweenAS3;
  20.     import org.libspark.betweenas3.easing.*;
  21.     import org.libspark.betweenas3.tweens.ITween;
  22.     [SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
  23.     public class Main extends Sprite
  24.     {
  25.         private static var P_ZERO:Point = new Point();
  26.         private static var F_BLUR:BlurFilter = new BlurFilter(44, BitmapFilterQuality.LOW);
  27.         private var _txt:TextField;
  28.         private var _hsv:ColorHSV;
  29.         private var _film:BitmapData;
  30.         private var _timer:Timer;
  31.         private var _activeParticles:Vector.<Particle>;
  32.         private var _inactiveParticles:Vector.<Particle>;
  33.         public function Main()
  34.         {
  35.             addEventListener(Event.ADDED_TO_STAGE, initialize);
  36.         }
  37.         private function initialize(evt:Event):void
  38.         {
  39.             removeEventListener(Event.ADDED_TO_STAGE, initialize);
  40.             SWFProfiler.init(this);
  41.             var i:uint,
  42.                 fmt:TextFormat,
  43.                 bm:Bitmap;
  44.             _activeParticles = new Vector.<Particle>();
  45.             _inactiveParticles = new Vector.<Particle>();
  46.             for (i=0; i<10000; i++)
  47.             {
  48.                 _inactiveParticles.push(new Particle());
  49.             }
  50.             _hsv = new ColorHSV(0111);
  51.             fmt = new TextFormat();
  52.             fmt.font = "Verdana";
  53.             fmt.bold = true;
  54.             fmt.size = 36;
  55.             _txt = new TextField();
  56.             _txt.defaultTextFormat = fmt;
  57.             _txt.autoSize = TextFieldAutoSize.LEFT;
  58.             _txt.text = "パァン!";
  59.             _film = new BitmapData(stage.stageWidth, stage.stageHeight, true0);
  60.             bm = new Bitmap(_film);
  61.             //bm.blendMode = BlendMode.ADD;
  62.             addChild(bm);
  63.             _timer = new Timer(0);
  64.             _timer.addEventListener(TimerEvent.TIMER, timerHandler);
  65.             _timer.start();
  66.             addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  67.         }
  68.         private function enterFrameHandler(evt:Event):void
  69.         {
  70.             var i:uint,
  71.                 p:Particle;
  72.             _hsv.h = ++_hsv.h % 360;
  73.             _film.lock();
  74.             _film.applyFilter(_film, _film.rect, P_ZERO, F_BLUR);
  75.             for (i=0; i<_activeParticles.length; i++)
  76.             {
  77.                 p = _activeParticles[i];
  78.                 p.x += p.vx;
  79.                 p.y += p.vy;
  80.                 p.life--;
  81.                 _film.setPixel32(p.x, p.y, p.color);
  82.                 if (!p.life)
  83.                 {
  84.                     _activeParticles.splice(i, 1);
  85.                     _inactiveParticles.push(p);
  86.                     i--;
  87.                 }
  88.             }
  89.             _film.unlock();
  90.         }
  91.         private function timerHandler(evt:TimerEvent):void
  92.         {
  93.             _timer.delay = (50 + Math.random() * 950) >> 0;
  94.             var sp:Sprite,
  95.                 bm:Bitmap,
  96.                 bmd:BitmapData,
  97.                 t:ITween;
  98.             //_hsv.h = ++_hsv.h % 360;
  99.             _txt.textColor = _hsv.value;
  100.             bmd = new BitmapData(_txt.width, _txt.height, true0);
  101.             bmd.draw(_txt);
  102.             bm = new Bitmap(bmd);
  103.             bm.smoothing = true;
  104.             bm.x -= bm.width >> 1;
  105.             bm.y -= bm.height >> 1;
  106.             sp = new Sprite();
  107.             sp.addChild(bm);
  108.             sp.x = (Math.random() * stage.stageWidth) >> 0;
  109.             sp.y = (Math.random() * stage.stageHeight) >> 0;
  110.             sp.scaleX = 0;
  111.             sp.scaleY = 0;
  112.             sp.rotation = (Math.random() * 360) >> 0;
  113.             //sp.blendMode = BlendMode.ADD;
  114.             addChild(sp);
  115.             t = BetweenAS3.serial(
  116.                 BetweenAS3.to(sp, {
  117.                     'scaleX'1,
  118.                     'scaleY'1,
  119.                     'rotation'0
  120.                 }, 2, Expo.easeIn),
  121.                 BetweenAS3.removeFromParent(sp)
  122.             );
  123.             t.onComplete = tweenComplete;
  124.             t.onCompleteParams = [sp, bm, bmd];
  125.             t.play();
  126.         }
  127.         private function tweenComplete(sp:Sprite, bm:Bitmap, bmd:BitmapData):void
  128.         {
  129.             var i:uint, j:uint, c:uint,
  130.                 cx:Number, cy:Number,
  131.                 angle:Number, strength:Number,
  132.                 p:Particle;
  133.             cx = sp.x + bm.x;
  134.             cy = sp.y + bm.y;
  135.             for (i=0; i<bmd.width; i++)
  136.             {
  137.                 for (j=0; j<bmd.height; j++)
  138.                 {
  139.                     c = bmd.getPixel32(i, j);
  140.                     if (!c) continue;
  141.                     p = _inactiveParticles.length ? _inactiveParticles.shift() : new Particle();
  142.                     angle = Math.random() * Math.PI * 2;
  143.                     strength = Math.random() * 20;
  144.                     p.vx = Math.cos(angle) * strength;
  145.                     p.vy = Math.sin(angle) * strength;
  146.                     p.x = cx + i;
  147.                     p.y = cy + j;
  148.                     p.color = c;
  149.                     p.life = 200;
  150.                     _activeParticles.push(p);
  151.                 }
  152.             }
  153.             bmd.dispose();
  154.         }
  155.     }
  156. }
  157. class Particle
  158. {
  159.     public var vx:Number;
  160.     public var vy:Number;
  161.     public var x:Number;
  162.     public var y:Number;
  163.     public var color:uint;
  164.     public var life:uint;
  165. }
noswf
  1. // forked from soundkitchen's パァン!
  2. package
  3. {
  4.     import flash.display.BlendMode;
  5.     import flash.display.Bitmap;
  6.     import flash.display.BitmapData;
  7.     import flash.display.Sprite;
  8.     import flash.events.Event;
  9.     import flash.events.TimerEvent;
  10.     import flash.text.TextField;
  11.     import flash.text.TextFieldAutoSize;
  12.     import flash.text.TextFormat;
  13.     import flash.filters.BitmapFilterQuality;
  14.     import flash.filters.BlurFilter;
  15.     import flash.geom.Point;
  16.     import flash.utils.Timer;
  17.     import com.flashdynamix.utils.SWFProfiler;
  18.     import frocessing.color.ColorHSV;
  19.     import org.libspark.betweenas3.BetweenAS3;
  20.     import org.libspark.betweenas3.easing.*;
  21.     import org.libspark.betweenas3.tweens.ITween;
  22.     [SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
  23.     public class Main extends Sprite
  24.     {
  25.         private static var P_ZERO:Point = new Point();
  26.         private static var F_BLUR:BlurFilter = new BlurFilter(44, BitmapFilterQuality.LOW);
  27.         private var _txt:TextField;
  28.         private var _hsv:ColorHSV;
  29.         private var _film:BitmapData;
  30.         private var _timer:Timer;
  31.         private var _activeParticles:Vector.<Particle>;
  32.         private var _inactiveParticles:Vector.<Particle>;
  33.         public function Main()
  34.         {
  35.             addEventListener(Event.ADDED_TO_STAGE, initialize);
  36.         }
  37.         private function initialize(evt:Event):void
  38.         {
  39.             removeEventListener(Event.ADDED_TO_STAGE, initialize);
  40.             SWFProfiler.init(this);
  41.             var i:uint,
  42.                 fmt:TextFormat,
  43.                 bm:Bitmap;
  44.             _activeParticles = new Vector.<Particle>();
  45.             _inactiveParticles = new Vector.<Particle>();
  46.             for (i=0; i<10000; i++)
  47.             {
  48.                 _inactiveParticles.push(new Particle());
  49.             }
  50.             _hsv = new ColorHSV(0111);
  51.             fmt = new TextFormat();
  52.             fmt.font = "Verdana";
  53.             fmt.bold = true;
  54.             fmt.size = 36;
  55.             _txt = new TextField();
  56.             _txt.defaultTextFormat = fmt;
  57.             _txt.autoSize = TextFieldAutoSize.LEFT;
  58.             _txt.text = "LOADING...";
  59.             _film = new BitmapData(stage.stageWidth, stage.stageHeight, true0);
  60.             bm = new Bitmap(_film);
  61.             //bm.blendMode = BlendMode.ADD;
  62.             addChild(bm);
  63.             _timer = new Timer(0);
  64.             _timer.addEventListener(TimerEvent.TIMER, timerHandler);
  65.             _timer.start();
  66.             addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  67.         }
  68.         private function enterFrameHandler(evt:Event):void
  69.         {
  70.             var i:uint,
  71.                 p:Particle;
  72.             _hsv.h = ++_hsv.h % 360;
  73.             _film.lock();
  74.             _film.applyFilter(_film, _film.rect, P_ZERO, F_BLUR);
  75.             for (i=0; i<_activeParticles.length; i++)
  76.             {
  77.                 p = _activeParticles[i];
  78.                 p.x += p.vx;
  79.                 p.y += p.vy;
  80.                 p.life--;
  81.                 _film.setPixel32(p.x, p.y, p.color);
  82.                 if (!p.life)
  83.                 {
  84.                     _activeParticles.splice(i, 1);
  85.                     _inactiveParticles.push(p);
  86.                     i--;
  87.                 }
  88.             }
  89.             _film.unlock();
  90.         }
  91.         private function timerHandler(evt:TimerEvent):void
  92.         {
  93.             _timer.delay = (50 + Math.random() * 950) >> 0;
  94.             var sp:Sprite,
  95.                 bm:Bitmap,
  96.                 bmd:BitmapData,
  97.                 t:ITween;
  98.             //_hsv.h = ++_hsv.h % 360;
  99.             _txt.textColor = _hsv.value;
  100.             bmd = new BitmapData(_txt.width, _txt.height, true0);
  101.             bmd.draw(_txt);
  102.             bm = new Bitmap(bmd);
  103.             bm.smoothing = true;
  104.             bm.x -= bm.width >> 1;
  105.             bm.y -= bm.height >> 1;
  106.             sp = new Sprite();
  107.             sp.addChild(bm);
  108.             sp.x = (Math.random() * stage.stageWidth) >> 0;
  109.             sp.y = (Math.random() * stage.stageHeight) >> 0;
  110.             sp.scaleX = 0;
  111.             sp.scaleY = 0;
  112.             sp.rotation = (Math.random() * 360) >> 0;
  113.             //sp.blendMode = BlendMode.ADD;
  114.             addChild(sp);
  115.             t = BetweenAS3.serial(
  116.                 BetweenAS3.to(sp, {
  117.                     'scaleX'1,
  118.                     'scaleY'1,
  119.                     'rotation'0
  120.                 }, 2, Expo.easeIn),
  121.                 BetweenAS3.removeFromParent(sp)
  122.             );
  123.             t.onComplete = tweenComplete;
  124.             t.onCompleteParams = [sp, bm, bmd];
  125.             t.play();
  126.         }
  127.         private function tweenComplete(sp:Sprite, bm:Bitmap, bmd:BitmapData):void
  128.         {
  129.             var i:uint, j:uint, c:uint,
  130.                 cx:Number, cy:Number,
  131.                 angle:Number, strength:Number,
  132.                 p:Particle;
  133.             cx = sp.x + bm.x;
  134.             cy = sp.y + bm.y;
  135.             for (i=0; i<bmd.width; i++)
  136.             {
  137.                 for (j=0; j<bmd.height; j++)
  138.                 {
  139.                     c = bmd.getPixel32(i, j);
  140.                     if (!c) continue;
  141.                     p = _inactiveParticles.length ? _inactiveParticles.shift() : new Particle();
  142.                     angle = Math.random() * Math.PI * 2;
  143.                     strength = Math.random() * 20;
  144.                     p.vx = Math.cos(angle) * strength;
  145.                     p.vy = Math.sin(angle) * strength;
  146.                     p.x = cx + i;
  147.                     p.y = cy + j;
  148.                     p.color = c;
  149.                     p.life = 200;
  150.                     _activeParticles.push(p);
  151.                 }
  152.             }
  153.             bmd.dispose();
  154.         }
  155.     }
  156. }
  157. class Particle
  158. {
  159.     public var vx:Number;
  160.     public var vy:Number;
  161.     public var x:Number;
  162.     public var y:Number;
  163.     public var color:uint;
  164.     public var life:uint;
  165. }
noswf
Get Adobe Flash Player