package {
//import
import flash.display.BlendMode;
import flash.utils.Timer;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.events.*;
import flash.display.LineScaleMode;
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.geom.ColorTransform;
[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="15")]
public class WonderFL extends MovieClip {
//public vars
public var n:Number
public var j:Number
public var t:Number
public var floor:Sprite;
public var span:int=10;
public var areaW:int=stage.stageWidth;
public var areaH:int=stage.stageHeight;
public var _canvasA:BitmapData;
public var _canvas:BitmapData;
public var bmp:Bitmap;
public var bmpA:Bitmap;
public var i:Number;
public var myTimerF:Timer;
public var R:int=130;
public var spaner:Number;
public var spaner2:Number;
public var col:Number;
public var px:Vector.<Number>;
public var py:Vector.<Number>;
public var ii:Number;
public var sa:Array;
public var myTimer:Timer;
public var myTimer2:Timer;
public var myTimer3:Timer;
public function WonderFL() {
spaner=Math.ceil(Math.random()*1000+1000);
spaner2=spaner*3;
col=0xFFFFFF*Math.random();
sa=new Array();
floor=new Sprite();
_canvas=new BitmapData(areaW,areaH,true,0x0);
bmp=new Bitmap(_canvas);
bmpA=new Bitmap(_canvasA);
bmp.blendMode=BlendMode.ADD;
addChild(bmp);
_canvasA=new BitmapData(areaW,areaH,true,0x0);
bmpA.blendMode=BlendMode.ADD;
addChild(bmpA);
myTimerF=new Timer(1000/50);
myTimerF.addEventListener("timer", update);
trace("init");
myTimerF.start();
for (i= 0; i <span; i++) {
sa.push(i);
}
myTimer=new Timer(10);
myTimer.addEventListener("timer", doEveryT);
myTimer.start();
myTimer2=new Timer(spaner);
myTimer2.addEventListener("timer", shuffleA);
myTimer2.start();
myTimer3=new Timer(spaner2);
myTimer3.addEventListener("timer", CA);
myTimer3.start();
}
private function prot():void {
px=new Vector.<Number>(span,true);
py=new Vector.<Number>(span,true);
for (i= 0; i < span; i++) {
ii=sa[i];
px[i]=(Math.random()*0.2+0.8)*R*Math.sin(3.14*2*ii/span)+230;
py[i]=(Math.random()*0.2+0.8)*R*Math.cos(3.14*2*ii/span)+230;
}
}
private function connect():void {
floor.graphics.clear();
floor.graphics.lineStyle(1, col, 1, false, LineScaleMode.VERTICAL,
CapsStyle.NONE, JointStyle.MITER, 10);
floor.graphics.moveTo((px[span-1]+px[0])/2,(py[span-1]+py[0])/2);
for (i= 1; i < span; i++) {
floor.graphics.curveTo(px[i-1],py[i-1],(px[i-1]+px[i])/2,(py[i-1]+py[i])/2);
}
floor.graphics.curveTo(px[span-1],py[span-1],(px[span-1]+px[0])/2,(py[span-1]+py[0])/2);
floor.graphics.endFill();
}
public function doEveryT(e:TimerEvent):void {
prot();
connect();
}
private function shuffleA(e:TimerEvent):void {
floor.rotation=360*(Math.random()-0.5);
n=sa.length;
i=n;
while (i--) {
j=Math.floor(Math.random()*n);
t=sa[i];
sa[i]=sa[j];
sa[j]=t;
}
}
private function CA(e:TimerEvent):void {
col=0xFFFFFF*Math.random();
}
private function update(e:Event):void {
_canvasA.fillRect(_canvasA.rect, 0x0);
_canvasA.draw(_canvas,null,new ColorTransform(1, 1, 1, 0.9, 0,0,0, 0));
this._canvas.fillRect(this._canvas.rect, 0x0);
this._canvas.draw(this._canvasA);
/*
*/
this._canvas.draw(floor);
}
}
}