// forked from fukt's forked from: Bounce // forked from butr0s's Bounce package { import flash.display.Sprite; [SWF(width="640", height="480", backgroundColor="0x003300", frameRate="30")] public class Bounce extends Sprite { public function Bounce():void { main = this; initialize(); } } } import flash.display.*; import flash.events.*; const SCREEN_WIDTH:int = 640, SCREEN_HEIGHT:int = 480; var main:Sprite, g:Graphics; var collections:Array = new Array(); var color:int = 0x00ff00; var ticks:int = 10; var start:Collection = new Collection(); function initialize():void { g = main.graphics; main.addEventListener(Event.ENTER_FRAME, update); } function update():void { g.clear(); ticks++; if(collections.length < 10 && ticks > 2) { ticks = 0; var blur:Collection = new Collection(); for(var i:int = 0; i < blur.contents.length; i++) { blur.contents[i].position.x = start.contents[i].position.x; blur.contents[i].position.y = start.contents[i].position.y; blur.contents[i].velocity.x = start.contents[i].velocity.x; blur.contents[i].velocity.y = start.contents[i].velocity.y; } collections.push(blur); } var thickness:int = 1, alpha:Number = 1; for each(var c:Collection in collections) { thickness += 0.1; alpha -= 0.0; c.update(thickness, color, alpha); } } class Collection { public var contents:Array = new Array(); public function Collection():void { contents.push(new Point()); contents.push(new Point()); contents.push(new Point()); contents.push(new Point()); } public function update(width:int = 3, color:int = 0xff0000, alpha:Number = 0.1):void { // Update individual points for each(var p:Point in contents) p.update(); // Draw lines g.lineStyle(width, color, alpha); g.moveTo(contents[contents.length - 1].position.x, contents[contents.length - 1].position.y); for each(p in contents) g.lineTo(p.position.x, p.position.y); } } class Point { public var position:Object = new Object; public var velocity:Object = new Object; public function Point():void { position.x = Math.random() * SCREEN_WIDTH; position.y = Math.random() * SCREEN_HEIGHT; velocity.x = Math.random() * 30; velocity.y = Math.random() * 30; } public function update():void { // Move position.x += velocity.x; position.y += velocity.y; if(position.x < 0 || position.x > SCREEN_WIDTH) velocity.x *= -1; if(position.y < 0 || position.y > SCREEN_HEIGHT) velocity.y *= -1; } } forked from: forked from: Bounce