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

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

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


forked from : bouze's hybrid-brush-01 [diff(8)]

FORKED
  1. // forked from bouze's hybrid-brush-02
  2. // forked from bouze's hybrid-brush-01
  3. package 
  4. {
  5.     import flash.display.Graphics;
  6.     import flash.display.Sprite;
  7.     import flash.events.Event;
  8.     import flash.geom.Point;
  9.     
  10.     /**
  11.      * ...
  12.      * @author bouze
  13.      */
  14.     public class Main extends Sprite
  15.     {
  16.         private var drawLayer:Sprite;
  17.         private var particles:Array = new Array();
  18.         private var pNum:int = 10;
  19.         private var maxDistance:Number = 20;
  20.         private var friction:Number = 0.3;
  21.         
  22.         public function Main()
  23.         {
  24.             init();
  25.         }
  26.         
  27.         private function init():void
  28.         {
  29.             drawLayer = new Sprite();
  30.             addChild(drawLayer);
  31.             initParticles();
  32.             addEventListener(Event.ENTER_FRAME, update);
  33.         }
  34.         
  35.         private function initParticles():void
  36.         {
  37.             var i:int;
  38.             for (i = 0; i < pNum; i++)
  39.             {
  40.                 
  41.                 var sp:Sprite = new Sprite();
  42.                 drawLayer.addChild( sp );
  43.                 /*
  44.                 var g:Graphics = sp.graphics;
  45.                 g.lineStyle( 1 );
  46.                 g.drawCircle( 0, 0, 4 );
  47.                 drawLayer.addChild( sp );
  48.                 */
  49.                 
  50.                 particles.push(
  51.                 {
  52.                     ref: sp,
  53.                     x: mouseX,
  54.                     y: mouseY,
  55.                     dx: 0,
  56.                     dy: 0
  57.                 } );
  58.             }
  59.         }
  60.         
  61.         private function move():void
  62.         {
  63.             var i:int;
  64.             for (i = 0; i < pNum; i++)
  65.             {
  66.                 var p:Object = particles[ i ];
  67.                 var pp:Object = particles[ i - 1 ];
  68.                 
  69.                 if ( i == 0 )
  70.                 {
  71.                     p.x += ( mouseX - p.x ) * friction;
  72.                     p.y += ( mouseY - p.y ) * friction;
  73.                 }
  74.                 else
  75.                 {
  76.                     p.x += ( pp.x - p.x ) * friction * ( pNum - i ) * 0.1;
  77.                     p.y += ( pp.y - p.y ) * friction * ( pNum - i ) * 0.1;
  78.                 }
  79.             }
  80.         }
  81.         
  82.         private function draw():void
  83.         {
  84.             var i:int;
  85.             for (i = 0; i < pNum - 5; i++) 
  86.             {
  87.                 var g:Graphics = particles[ i ].ref.graphics;
  88.                 g.clear();
  89.                 g.beginFill( 0x001F1F * i );
  90.                 //g.lineStyle(1);
  91.                 
  92.                 g.moveTo( particles[ i ].x, particles[ i ].y );
  93.                 g.lineTo( particles[ i + 1 ].x, particles[ i + 1 ].y );
  94.                 g.lineTo( particles[ i + 2 ].x, particles[ i + 2 ].y );
  95.                 g.lineTo( particles[ i + 3 ].x, particles[ i + 3 ].y );
  96.                 g.lineTo( particles[ i + 4 ].x, particles[ i + 4 ].y );
  97.                 g.lineTo( particles[ i + 5 ].x, particles[ i + 5 ].y );
  98.                 g.lineTo( particles[ i ].x, particles[ i ].y );
  99.             }
  100.             g.endFill();
  101.         }
  102.         
  103.         private function update(e:Event):void
  104.         {
  105.             move();
  106.             draw();
  107.         }
  108.     }
  109. }
noswf
Get Adobe Flash Player