flash on 2016-2-18
lineToで書いてみました。@nulldesign
♥1 |
Line 78 |
Modified 2016-02-18 22:09:47 |
MIT License
archived:2017-03-05 14:18:41
ActionScript3 source code
/**
* Copyright Alexandr.Viktorovich ( http://wonderfl.net/user/Alexandr.Viktorovich )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/kHXV
*/
// forked from nulldesign's UnyoUnyo
package
{
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.geom.*;
import flash.filters.GlowFilter;
import flash.ui.Mouse;
/*
lineToで書いてみました。@nulldesign
*/
[SWF(width="465", height="465", backgroundColor="0x0F1854") ]
public class UnyoUnyo extends Sprite
{
private const AllNums:uint = 1;
private const SECTION:uint = 11;
private var sectionList:Array = [];
public function UnyoUnyo():void
{
addEventListener( Event.ADDED_TO_STAGE, initialize );
}
private function initialize( e:Event ):void
{
Mouse.hide();
removeEventListener( Event.ADDED_TO_STAGE, initialize );
var _w:Number = stage.stageWidth;
var _h:Number = stage.stageHeight ;
for( var z:uint = 0; z < AllNums; z++ )
{
var _px:Number = Math.random() * _w;
var _py:Number = Math.random() * _h;
var _list:Array = [];
for( var i:uint = 0; i < SECTION; i++ )
{
var _sec:SectionData = new SectionData( _px, _py );
_list.push( _sec );
}
sectionList.push( _list );
}
//動きます
addEventListener( Event.ENTER_FRAME, loop );
}
private function loop( e:Event ):void
{
var delayVal:Number = .7;
//画面を一度きれいにしてから描画
this.graphics.clear();
for( var z:uint = 0; z < AllNums; z++ )
{
var _list:Array = sectionList[z];
var _sec:SectionData = _list[0] as SectionData;
var _secP:SectionData;
_sec.x = mouseX;
_sec.y = mouseY;
this.graphics.moveTo( _sec.x, _sec.y );
this.graphics.lineStyle( 12, 0x000000 );
for( var i:uint = 1; i < SECTION; i++ )
{
_sec = _list[i] as SectionData;
_secP = _list[i-1] as SectionData;
_sec.x += ( _secP.x - _sec.x ) * delayVal;
_sec.y += ( _secP.y - _sec.y ) * delayVal;
}
for( i = 0; i < SECTION; i++ )
{
_sec = _list[i] as SectionData;
this.graphics.lineStyle( ( SECTION - i ) * .75 + 2.5, 0x999999 );
this.graphics.lineTo( _sec.x, _sec.y );
}
}
}
}
}
class SectionData
{
public var x:Number;
public var y:Number;
public function SectionData( _x:Number = 0, _y:Number = 0 ):void
{
this.x = _x;
this.y = _y;
}
}