forked from: forked from: Curvosya
/**
* Copyright fukt ( http://wonderfl.net/user/fukt )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qBV5
*/
// forked from FTMSuperfly's forked from: Curvosya
// forked from GreekFellows's Curvosya
package
{
import flash.display.Sprite;
import flash.events.Event;
public class Curvosya extends Sprite
{
public function Curvosya()
{
this.x = 465 / 2;
this.y = 465 / 2;
for (var it:int = 0; it < 100; it++)
{
var c:Curvos = new Curvos();
c.x = Math.random() * 465 - 465 / 2;
c.y = Math.random() * 465 - 465 / 2;
this.addChild(c);
}
this.addEventListener(Event.ENTER_FRAME, curvosya);
}
public function curvosya(e:Event):void
{
if (this.numChildren < 100)
{
for (var num:int = 0; num < 100 - this.numChildren; num++)
{
var c:Curvos = new Curvos();
c.x = Math.random() * 465 - 465 / 2;
c.y = Math.random() * 465 - 465 / 2;
this.addChildAt(c, 0);
}
}
}
}
}
import flash.display.Sprite;
import flash.events.Event;
class Curvos extends Sprite
{
public var array:Array;
public var color:uint = Math.floor(Math.random() * 0xffffff);
public var ax:Number = 0;
public var ay:Number = 0;
public function Curvos()
{
vertices();
}
public function vertices():void
{
array = [];
array.push({x:- (Math.floor(Math.random() * 50) + 50), y:- (Math.floor(Math.random() * 50) + 50), dx:0, dy:0, maxx:-20, minx: -200, maxy:-20, miny:-240});
array.push({x:0, y:- (Math.floor(Math.random() * 80) + 20), dy:0, maxy:-20, miny:-100});
array.push({x:(Math.floor(Math.random() * 50) + 50), y:- (Math.floor(Math.random() * 50) + 50), dx:0, dy:0, maxx:200, minx: 20, maxy:-20, miny:-240});
array.push({x:(Math.floor(Math.random() * 80) + 20), y:0, dx:0, maxx:100, minx:20});
array.push({x:(Math.floor(Math.random() * 50) + 50), y:(Math.floor(Math.random() * 50) + 50), dx:0, dy:0, maxx:200, minx: 20, maxy:200, miny:20});
array.push({x:0, y:(Math.floor(Math.random() * 80) + 20), dy:0, maxy:100, miny:20});
array.push({x:- (Math.floor(Math.random() * 50) + 50), y:(Math.floor(Math.random() * 50) + 50), dx:0, dy:0, maxx:-20, minx: -200, maxy:200, miny:20});
array.push({x:- (Math.floor(Math.random() * 80) + 20), y:0, dx:0, maxx:-20, minx:-100});
draw();
this.addEventListener(Event.ENTER_FRAME, curvos);
}
public function curvos(e:Event):void
{
this.x += ax;
this.y += ay;
ax += (Math.random() * 10 - 5) / 10;
ay += (Math.random() * 10 - 5) / 10;
if (this.x > 465 / 2 + this.width / 2 || this.x < -465 / 2 - this.width / 2 || this.y > 465 / 2 + this.height / 2 || this.y < -465 / 2 - this.height / 2)
{
parent.removeChild(this);
this.removeEventListener(Event.ENTER_FRAME, curvos);
}
for (var ci:int = 0; ci < array.length; ci++)
{
if (array[ci].dx != undefined)
{
array[ci].x += array[ci].dx;
array[ci].dx += Math.floor(Math.random() * 100 - 50) / 100;
if (array[ci].x > array[ci].maxx) array[ci].dx = - Math.abs(array[ci].dx);
if (array[ci].x < array[ci].minx) array[ci].dx = Math.abs(array[ci].dx);
if (array[ci].dx > 10) array[ci].dx = 5;
if (array[ci].dx < -10) array[ci].dx = -5;
}
if (array[ci].dy != undefined)
{
array[ci].y += array[ci].dy;
array[ci].dy += Math.floor(Math.random() * 100 - 50) / 100;
if (array[ci].y > array[ci].maxy) array[ci].dy = - Math.abs(array[ci].dy);
if (array[ci].y < array[ci].miny) array[ci].dy = Math.abs(array[ci].dy);
if (array[ci].dy > 10) array[ci].dy = 5;
if (array[ci].dy < -10) array[ci].dy = -5;
}
}
draw();
}
public function draw():void
{
this.graphics.clear();
this.graphics.beginFill(color, 1);
this.graphics.moveTo(array[0].x + (array[1].x - array[0].x) / 2, array[0].y + (array[1].y - array[0].y) / 2);
for (var di:int = 1; di < array.length - 1; di++)
{
this.graphics.curveTo(array[di].x, array[di].y, array[di].x +(array[di + 1].x - array[di].x) / 2, array[di].y + (array[di + 1].y - array[di].y) / 2);
}
this.graphics.curveTo(array[array.length - 1].x, array[array.length - 1].y, array[array.length - 1].x + (array[0].x - array[array.length - 1].x) / 2, array[array.length - 1].y + (array[0].y - array[array.length - 1].y) / 2);
this.graphics.curveTo(array[0].x, array[0].y, array[0].x + (array[1].x - array[0].x) / 2, array[0].y + (array[1].y - array[0].y) / 2);
}
}