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

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

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


FORKED
  1. // forked from seagirl's Filter
  2. package
  3. {
  4.     import flash.display.Sprite;
  5.     import flash.display.StageAlign;
  6.     import flash.display.StageScaleMode;
  7.     import flash.events.Event;
  8.     
  9.     import org.libspark.thread.EnterFrameThreadExecutor;
  10.     import org.libspark.thread.Thread;
  11.     
  12.     [SWF(backgroundColor="#000000")]
  13.     
  14.     public class Filter extends Sprite
  15.     {
  16.         public function Filter()
  17.         {
  18.             super();
  19.             
  20.             Thread.initialize(new EnterFrameThreadExecutor());
  21.             
  22.             new MainThread(this).start();
  23.             
  24.             addEventListener(Event.ADDED_TO_STAGE, addToStageHandler);
  25.         }
  26.         
  27.         private function addToStageHandler(event:Event):void
  28.         {
  29.             stage.scaleMode = StageScaleMode.NO_SCALE;
  30.             stage.align = StageAlign.TOP_LEFT;            
  31.         }
  32.         
  33.     }
  34. }
  35. import org.libspark.thread.Thread;
  36. import flash.display.Bitmap;
  37. import flash.display.Sprite;
  38. import flash.events.Event;
  39.     
  40. class MainThread extends Thread
  41. {
  42.     private static const BASE_URL:String = 'http://seagirl.jp/assets/images/';
  43.     
  44.     private static const WIDTH:int = 700;
  45.     private static const HEIGHT:int = 700;
  46.         
  47.     private static const VELOCITY:int = 1;
  48.     private static const DEGREE:int = 310;
  49.     private static const RANGE:int = 1200;
  50.     
  51.     public function MainThread(document:Sprite)
  52.     {
  53.         this.document = document;
  54.     }
  55.     
  56.     private var document:Sprite;
  57.     private var target:Bitmap;
  58.     
  59.     private var velocity:Number;
  60.     private var angle:Number;
  61.     
  62.     private var assets:Array = [];
  63.     private var assetsLoader:Executor;
  64.     
  65.     private var filters:Array;
  66.     
  67.     override protected function run():void
  68.     {
  69.         next(loadAssets);
  70.     }
  71.     
  72.     private function loadAssets():void
  73.     {
  74.         assetsLoader = new ParallelExecutor();
  75.         assetsLoader.addThread(new LoaderThread(new URLRequest(BASE_URL + '6.jpg'), new LoaderContext(true)));
  76.         assetsLoader.addThread(new LoaderThread(new URLRequest(BASE_URL + '2.jpg'), new LoaderContext(true)));
  77.         assetsLoader.start();
  78.         assetsLoader.join();
  79.         
  80.         next(assetsDidLoaded);
  81.     }
  82.     
  83.     private function assetsDidLoaded():void
  84.     {
  85.         for (var i:int = 0; i < assetsLoader.numThreads; i++)
  86.         {
  87.             assets.push(LoaderThread(assetsLoader.getThreadAt(i)).loader.content);
  88.         }
  89.         
  90.         next(show);
  91.     }
  92.     
  93.     private function show():void
  94.     {
  95.         velocity = VELOCITY / 1000;
  96.         angle = Math.PI / 180 * DEGREE;
  97.             
  98.         target = Bitmap(assets[0]);
  99.         target.alpha = 0;
  100.         target.x = (document.stage.stageWidth - target.width) / 2;
  101.         target.y = (document.stage.stageHeight - target.height) / 2;
  102.         document.addChild(target);
  103.         
  104.         document.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  105.     }
  106.     
  107.     private function enterFrameHandler(event:Event):void
  108.     {
  109.         var amplitude:Number = Math.sin(angle);
  110.         var scale:Number = amplitude * 1200;
  111.         
  112.         if (amplitude >= -0.7)
  113.         {
  114.             if (document.hasEventListener(Event.ENTER_FRAME))
  115.                 document.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
  116.         }
  117.         
  118.         target.filters =
  119.         [
  120.             new GradientRadialFilter(scale, scale, WIDTH, HEIGHT, Bitmap(assets[1]).bitmapData).create()
  121.         ];
  122.         
  123.         target.alpha = 1;
  124.         target.width = Math.abs(Math.cos(angle)) * WIDTH;
  125.         target.height = Math.abs(Math.cos(angle)) * HEIGHT;
  126.         target.x = (document.stage.stageWidth - target.width) / 2;
  127.         target.y = (document.stage.stageHeight - target.height) / 2;  
  128.         
  129.         angle += velocity;
  130.     }
  131. }
  132. import flash.display.BitmapData;
  133. import flash.display.BitmapDataChannel;
  134. import flash.display.GradientType;
  135. import flash.display.Sprite;
  136. import flash.filters.BitmapFilter;
  137. import flash.filters.DisplacementMapFilter;
  138. import flash.filters.DisplacementMapFilterMode;
  139. import flash.geom.Matrix;
  140. import flash.geom.Point;
  141. import org.libspark.thread.utils.Executor;
  142. import org.libspark.thread.utils.ParallelExecutor;
  143. import org.libspark.thread.threads.display.LoaderThread;
  144. import flash.net.URLRequest;
  145. import flash.system.LoaderContext;
  146. class GradientRadialFilter
  147. {
  148.     
  149.     public function GradientRadialFilter(scaleX:Number = 0.0,
  150.                                          scaleY:Number = 0.0,
  151.                                          width:int = 0,
  152.                                          height:int = 0,
  153.                                          mapBitmap:BitmapData = null,
  154.                                          mapPoint:Point = null,
  155.                                          componentX:uint = 4,
  156.                                          componentY:uint = 1,
  157.                                          mode:String = "color",
  158.                                          color:uint = 0,
  159.                                          alpha:Number = 0.0
  160.                                         )
  161.     {
  162.         if (mapBitmap == null)
  163.             mapBitmap = createMapBitmap(width, height, [100255]);
  164.             
  165.         bitmapFilter = new DisplacementMapFilter(mapBitmap,
  166.                                                  mapPoint,
  167.                                                  componentX,
  168.                                                  componentY,
  169.                                                  scaleX,
  170.                                                  scaleY,
  171.                                                  mode,
  172.                                                  color,
  173.                                                  alpha
  174.                                                 );
  175.     }
  176.     
  177.     private var bitmapFilter:BitmapFilter;
  178.     
  179.     public function create():BitmapFilter
  180.     {
  181.         return bitmapFilter;
  182.     }
  183.     
  184.     private function createMapBitmap(width:int, height:int, ratio:Array):BitmapData
  185.     {
  186.         var matrix:Matrix = new Matrix();
  187.         matrix.createGradientBox(width, height, 000);
  188.         
  189.         var map:Sprite = new Sprite();
  190.         map.graphics.beginGradientFill(GradientType.RADIAL, [0xff0000, 0x0000ff], [11], ratio, matrix);
  191.         map.graphics.drawRect(00, width, height);
  192.         map.graphics.endFill();
  193.         
  194.         var mapBitmap:BitmapData = new BitmapData(width, height, true0);
  195.         mapBitmap.draw(map);
  196.         
  197.         return mapBitmap;
  198.     }
  199. }
noswf
  1. // forked from seagirl's Filter
  2. package
  3. {
  4.     import flash.display.Sprite;
  5.     import flash.display.StageAlign;
  6.     import flash.display.StageScaleMode;
  7.     import flash.events.Event;
  8.     
  9.     import org.libspark.thread.EnterFrameThreadExecutor;
  10.     import org.libspark.thread.Thread;
  11.     
  12.     [SWF(backgroundColor="#000000")]
  13.     
  14.     public class Filter extends Sprite
  15.     {
  16.         public function Filter()
  17.         {
  18.             super();
  19.             
  20.             Thread.initialize(new EnterFrameThreadExecutor());
  21.             
  22.             new MainThread(this).start();
  23.             
  24.             addEventListener(Event.ADDED_TO_STAGE, addToStageHandler);
  25.         }
  26.         
  27.         private function addToStageHandler(event:Event):void
  28.         {
  29.             stage.scaleMode = StageScaleMode.NO_SCALE;
  30.             stage.align = StageAlign.TOP_LEFT;            
  31.         }
  32.         
  33.     }
  34. }
  35. import org.libspark.thread.Thread;
  36. import flash.display.Bitmap;
  37. import flash.display.Sprite;
  38. import flash.events.Event;
  39.     
  40. class MainThread extends Thread
  41. {
  42.     private static const BASE_URL:String = 'http://seagirl.jp/assets/images/';
  43.     
  44.     private static const WIDTH:int = 700;
  45.     private static const HEIGHT:int = 700;
  46.         
  47.     private static const VELOCITY:int = 1;
  48.     private static const DEGREE:int = 310;
  49.     private static const RANGE:int = 1200;
  50.     
  51.     public function MainThread(document:Sprite)
  52.     {
  53.         this.document = document;
  54.     }
  55.     
  56.     private var document:Sprite;
  57.     private var target:Bitmap;
  58.     
  59.     private var velocity:Number;
  60.     private var angle:Number;
  61.     
  62.     private var assets:Array = [];
  63.     private var assetsLoader:Executor;
  64.     
  65.     private var filters:Array;
  66.     
  67.     override protected function run():void
  68.     {
  69.         next(loadAssets);
  70.     }
  71.     
  72.     private function loadAssets():void
  73.     {
  74.         assetsLoader = new ParallelExecutor();
  75.         assetsLoader.addThread(new LoaderThread(new URLRequest(BASE_URL + '6.jpg'), new LoaderContext(true)));
  76.         assetsLoader.addThread(new LoaderThread(new URLRequest(BASE_URL + '2.jpg'), new LoaderContext(true)));
  77.         assetsLoader.start();
  78.         assetsLoader.join();
  79.         
  80.         next(assetsDidLoaded);
  81.     }
  82.     
  83.     private function assetsDidLoaded():void
  84.     {
  85.         for (var i:int = 0; i < assetsLoader.numThreads; i++)
  86.         {
  87.             assets.push(LoaderThread(assetsLoader.getThreadAt(i)).loader.content);
  88.         }
  89.         
  90.         next(show);
  91.     }
  92.     
  93.     private function show():void
  94.     {
  95.         velocity = VELOCITY / 1000;
  96.         angle = Math.PI / 180 * DEGREE;
  97.             
  98.         target = Bitmap(assets[0]);
  99.         target.alpha = 0;
  100.         target.x = (document.stage.stageWidth - target.width) / 2;
  101.         target.y = (document.stage.stageHeight - target.height) / 2;
  102.         document.addChild(target);
  103.         
  104.         document.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  105.     }
  106.     
  107.     private function enterFrameHandler(event:Event):void
  108.     {
  109.         var amplitude:Number = Math.sin(angle);
  110.         var scale:Number = amplitude * 1200;
  111.         
  112.         if (amplitude >= -0.7)
  113.         {
  114.             if (document.hasEventListener(Event.ENTER_FRAME))
  115.                 document.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
  116.         }
  117.         
  118.         target.filters =
  119.         [
  120.             new GradientRadialFilter(scale, scale, WIDTH, HEIGHT, Bitmap(assets[1]).bitmapData).create()
  121.         ];
  122.         
  123.         target.alpha = 1;
  124.         target.width = Math.abs(Math.cos(angle)) * WIDTH;
  125.         target.height = Math.abs(Math.cos(angle)) * HEIGHT;
  126.         target.x = (document.stage.stageWidth - target.width) / 2;
  127.         target.y = (document.stage.stageHeight - target.height) / 2;  
  128.         
  129.         angle += velocity;
  130.     }
  131. }
  132. import flash.display.BitmapData;
  133. import flash.display.BitmapDataChannel;
  134. import flash.display.GradientType;
  135. import flash.display.Sprite;
  136. import flash.filters.BitmapFilter;
  137. import flash.filters.DisplacementMapFilter;
  138. import flash.filters.DisplacementMapFilterMode;
  139. import flash.geom.Matrix;
  140. import flash.geom.Point;
  141. import org.libspark.thread.utils.Executor;
  142. import org.libspark.thread.utils.ParallelExecutor;
  143. import org.libspark.thread.threads.display.LoaderThread;
  144. import flash.net.URLRequest;
  145. import flash.system.LoaderContext;
  146. class GradientRadialFilter
  147. {
  148.     
  149.     public function GradientRadialFilter(scaleX:Number = 0.0,
  150.                                          scaleY:Number = 0.0,
  151.                                          width:int = 0,
  152.                                          height:int = 0,
  153.                                          mapBitmap:BitmapData = null,
  154.                                          mapPoint:Point = null,
  155.                                          componentX:uint = 4,
  156.                                          componentY:uint = 1,
  157.                                          mode:String = "color",
  158.                                          color:uint = 0,
  159.                                          alpha:Number = 0.0
  160.                                         )
  161.     {
  162.         if (mapBitmap == null)
  163.             mapBitmap = createMapBitmap(width, height, [100255]);
  164.             
  165.         bitmapFilter = new DisplacementMapFilter(mapBitmap,
  166.                                                  mapPoint,
  167.                                                  componentX,
  168.                                                  componentY,
  169.                                                  scaleX,
  170.                                                  scaleY,
  171.                                                  mode,
  172.                                                  color,
  173.                                                  alpha
  174.                                                 );
  175.     }
  176.     
  177.     private var bitmapFilter:BitmapFilter;
  178.     
  179.     public function create():BitmapFilter
  180.     {
  181.         return bitmapFilter;
  182.     }
  183.     
  184.     private function createMapBitmap(width:int, height:int, ratio:Array):BitmapData
  185.     {
  186.         var matrix:Matrix = new Matrix();
  187.         matrix.createGradientBox(width, height, 000);
  188.         
  189.         var map:Sprite = new Sprite();
  190.         map.graphics.beginGradientFill(GradientType.RADIAL, [0xff0000, 0x0000ff], [11], ratio, matrix);
  191.         map.graphics.drawRect(00, width, height);
  192.         map.graphics.endFill();
  193.         
  194.         var mapBitmap:BitmapData = new BitmapData(width, height, true0);
  195.         mapBitmap.draw(map);
  196.         
  197.         return mapBitmap;
  198.     }
  199. }
noswf
Get Adobe Flash Player