うねうねうねうね
増やしてみた
/**
* Copyright 178ep3 ( http://wonderfl.net/user/178ep3 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/w0MG
*/
//増やしてみた
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
public class Arm extends Sprite
{
private var _list:Array = [];
private var _max:uint = 12;
public function Arm()
{
init();
addEventListener(Event.ENTER_FRAME,loop);
}
private function init():void
{
var i:uint;
for (i = 0; i < _max; i++)
{
var a:Arms = addChild(new Arms(stage,0,stage.stageHeight)) as Arms;
a.x = stage.stageWidth / _max * i + (stage.stageWidth/_max/2);
_list.push(a);
var b:Arms = addChild(new Arms(stage)) as Arms;
b.rotation = 90;
b.y = stage.stageWidth / _max * i + (stage.stageWidth / _max / 2);
_list.push(b);
var c:Arms = addChild(new Arms(stage)) as Arms;
c.rotation = 180;
c.x = stage.stageWidth / _max * i + (stage.stageWidth / _max / 2);
_list.push(c);
var d:Arms = addChild(new Arms(stage,0,stage.stageHeight)) as Arms;
d.rotation = -90;
d.y = stage.stageWidth / _max * i + (stage.stageWidth / _max / 2);
_list.push(d);
}
}
private function loop(e:Event):void
{
for (var i:uint = 0; i < _max*4; i++)
{
_list[i].Move();
}
}
}
}
import flash.display.Stage;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
class Arms extends Sprite
{
private var _maxNum:uint = 10;
private var _xList:Array = new Array(_maxNum);
private var _yList:Array = new Array(_maxNum);
private var _aList:Array = new Array(_maxNum);
private var _length:Number = 20;
private var _targetX:Number;
private var _targetY:Number;
private var _stage:Stage;
public function Arms(stg:Stage, _x:uint = 0, _y:uint=0 )
{
_stage = stg;
for(var i:uint=0; i<_maxNum; i++)
{
_xList[i] = 0;
_yList[i] = 0;
_aList[i] = 0;
}
_xList[_maxNum-1] = _x;
_yList[_maxNum-1] = _y;
}
public function Move():void
{
this.graphics.clear();
Angle(0,mouseX,mouseY);
var i:uint;
for(i=1; i<_maxNum; i++)
{
Angle(i,_targetX,_targetY);
}
for(i=_maxNum-1; i>=1; i--)
{
Position(i,i-1);
}
for(i=0; i<_maxNum; i++)
{
draw(_xList[i],_yList[i],_aList[i],(i+1)*2,i);
}
}
private function Angle(i:uint, _x:Number, _y:Number):void
{
var dx:Number = _x - _xList[i];
var dy:Number = _y - _yList[i];
_aList[i] = Math.atan2(dy,dx);
_targetX = _x - Math.cos(_aList[i]) * _length;
_targetY = _y - Math.sin(_aList[i]) * _length;
}
private function Position(a:uint,b:uint):void
{
_xList[b] = _xList[a] + Math.cos(_aList[a]) * _length;
_yList[b] = _yList[a] + Math.sin(_aList[a]) * _length;
}
private function draw(_x:Number, _y:Number, _a:Number, _s:Number,i:uint):void
{
this.graphics.lineStyle(_s,0x000000,0.5);
this.graphics.moveTo(_x,_y);
var p:Point = Point.polar(_length,_a);
this.graphics.lineTo(p.x+_x ,p.y+_y);
this.graphics.endFill();
}
}