/**
* Copyright YoupSolo ( http://wonderfl.net/user/YoupSolo )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8iy6
*/
// forked from mutantleg's flash on 2015-12-20
package {
import flash.filters.BlurFilter;
import flash.display.StageQuality;
import flash.events.Event;
import flash.display.Sprite;
import flash.display.Shape;
public class FlashTest extends Sprite {
public function FlashTest() {
stage.quality = StageQuality.MEDIUM;
vecSpr = new Vector.<xSpr>(0,false);
var a:xSpr; var i:int;
for (i=0;i<256;i+=1)
{ a=new xSpr();
a.cx =Math.random()*465; a.cy = Math.random()*465;
a.sp = Math.random()*4+1;
vecSpr.push(a); }
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var vecSpr:Vector.<xSpr>;
public function getMag(ax:Number,ay:Number):Number
{ return Math.sqrt(ax*ax+ay*ay); }
public function onEnter(e:Event):void
{
var a:xSpr; var i:int; var ta:Number; var num:int;
var d:Number;
var px:Number; var py:Number;
graphics.clear();
graphics.beginFill(0x0);
graphics.drawRect(0,0,stage.stageWidth, stage.stageHeight);
graphics.endFill();
graphics.lineStyle(2,0x8080FF);
num = vecSpr.length;
for(i=0;i<num;i+=1)
{
a = vecSpr[i];
ta = Math.atan2(a.cy-235,a.cx-235);
d = getMag(a.cx-235,a.cy-235);
d/= 64;
d*=a.sp;
px = a.cx; py = a.cy;
a.cx += Math.cos(ta) * d;
a.cy += Math.sin(ta) * d;
graphics.moveTo(px,py);
graphics.lineTo(a.cx,a.cy);
if (a.cx>465||a.cx<0||a.cy<0||a.cy>=465)
{ a.cx=235+Math.random()*50-25; a.cy=235+Math.random()*50-25; a.sp = Math.random()*15+1; }
}//nexti
}//onenter
}//classend
}
internal class xSpr
{
public var cx:Number = 0;
public var cy:Number = 0;
public var sp:Number = 1;
}//xspr