Section 1
//ImaginationPoint (com.neave.imagination.ImaginationPoint)
package com.neave.imagination {
class ImaginationPoint {
var color:uint;
var size:Number;
var dx:Number;
var dy:Number;
var x:Number;
var y:Number;
function ImaginationPoint(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:uint){
this.x = _arg1;
this.y = _arg2;
this.dx = _arg3;
this.dy = _arg4;
this.size = _arg5;
this.color = _arg6;
}
}
}//package com.neave.imagination
Section 2
//NeaveImagination (com.neave.imagination.NeaveImagination)
package com.neave.imagination {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import com.neave.link.*;
public class NeaveImagination {
private const BLUE_STEP:Number = 0.025;
private const GREEN_STEP:Number = 0.015;
private const MAX_LENGTH:int = 80;
private const RED_STEP:Number = 0.02;
private const SPREAD_MIN:int = 1;
private const SPREAD_MAX:int = 40;
private var green:Number;
private var px:Number;
private var bmp:Bitmap;
private var blackBitmap:BitmapData;
private var py:Number;
private var red:Number;
private var container:DisplayObjectContainer;
private var list:Array;
private var canvasHeight:int;
private var size:Number;
private var paused:Boolean;
private var canvasWidth:int;
private var blur:BlurFilter;
private var blue:Number;
private var spread:int;
private var m:Matrix;
private var p:Point;
private var link:NeaveLink;
private var stage:Stage;
private var lines:Shape;
public function NeaveImagination(_arg1:DisplayObjectContainer, _arg2:int=770, _arg3:int=400){
this.container = _arg1;
stage = _arg1.stage;
canvasWidth = _arg2;
canvasHeight = _arg3;
initStage();
initLines();
initBitmap();
initLink();
setFullScreenQuality();
}
private function drawBitmap():void{
var _local1:BitmapData;
_local1 = bmp.bitmapData;
_local1.lock();
_local1.merge(blackBitmap, _local1.rect, p, 4, 4, 4, 0);
_local1.applyFilter(_local1, _local1.rect, p, blur);
_local1.draw(lines, m, null, BlendMode.ADD);
_local1.unlock();
}
private function disposeBitmaps():void{
bmp.bitmapData.dispose();
bmp.bitmapData = null;
blackBitmap.dispose();
blackBitmap = null;
}
private function mouseUpListener(_arg1:MouseEvent):void{
spread = SPREAD_MAX;
}
private function drawLines():void{
var _local1:Graphics;
var _local2:int;
_local1 = lines.graphics;
_local1.clear();
_local1.moveTo(px, py);
_local2 = (list.length - 1);
while (_local2 > 0) {
list[_local2].x = (list[_local2].x + list[_local2].dx);
list[_local2].y = (list[_local2].y + list[_local2].dy);
_local1.lineStyle(list[_local2].size, list[_local2].color, ((((list.length > (MAX_LENGTH - 8))) && ((_local2 < 8)))) ? (_local2 / 8) : 1);
_local1.curveTo(list[_local2].x, list[_local2].y, ((list[_local2].x + list[(_local2 - 1)].x) / 2), ((list[_local2].y + list[(_local2 - 1)].y) / 2));
if (list.length > MAX_LENGTH){
list.splice(0, 1);
};
_local2--;
};
}
private function stageResizeListener(_arg1:Event):void{
container.removeChild(bmp);
disposeBitmaps();
initBitmap();
initLink();
}
public function destroy():void{
stage.removeEventListener(Event.RESIZE, stageResizeListener);
stage.removeEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener);
stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
stage.removeEventListener(FullScreenEvent.FULL_SCREEN, setFullScreenQuality);
stage.removeEventListener(Event.ENTER_FRAME, update);
container.removeChild(bmp);
disposeBitmaps();
link.destroy();
}
private function initLink():void{
if (link){
link.destroy();
};
link = new NeaveLink(container, canvasWidth, canvasHeight);
}
private function mouseDownListener(_arg1:MouseEvent):void{
spread = SPREAD_MIN;
}
private function update(_arg1:Event):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:uint;
if (paused){
return;
};
_local2 = ((((container.mouseX - px) + (Math.random() * 4)) - 2) / 2);
_local3 = ((((container.mouseY - py) + (Math.random() * 4)) - 2) / 2);
if (_local2 < -(spread)){
_local2 = -(spread);
};
if (_local2 > spread){
_local2 = spread;
};
if (_local3 < -(spread)){
_local3 = -(spread);
};
if (_local3 > spread){
_local3 = spread;
};
px = container.mouseX;
py = container.mouseY;
_local4 = ((Math.sin((size = (size + 0.2))) * 8) + 4);
_local5 = (((((Math.sin((red = (red + RED_STEP))) * 128) + 127) << 16) | (((Math.sin((green = (green + GREEN_STEP))) * 128) + 127) << 8)) | ((Math.sin((blue = (blue + BLUE_STEP))) * 128) + 127));
list.push(new ImaginationPoint(px, py, _local2, _local3, _local4, _local5));
drawLines();
drawBitmap();
}
private function initLines():void{
list = new Array();
px = (py = (size = 0));
spread = SPREAD_MAX;
paused = false;
red = 0;
green = 0xFF;
blue = 0xFF;
lines = new Shape();
}
private function initStage():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, stageResizeListener);
stage.addEventListener(Event.MOUSE_LEAVE, mouseLeaveListener);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpListener);
stage.addEventListener(FullScreenEvent.FULL_SCREEN, setFullScreenQuality);
stage.addEventListener(Event.ENTER_FRAME, update);
}
private function initBitmap():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:int;
_local1 = stage.stageWidth;
_local2 = stage.stageHeight;
_local3 = Math.ceil((_local1 / 2));
_local4 = Math.ceil((_local2 / 2));
bmp = new Bitmap(new BitmapData(_local3, _local4, false, 4278190080));
bmp.smoothing = true;
bmp.scaleX = (bmp.scaleY = 2);
bmp.x = ((canvasWidth - _local1) / 2);
bmp.y = ((canvasHeight - _local2) / 2);
container.addChild(bmp);
blackBitmap = new BitmapData(_local3, _local4, false, 4278190080);
m = new Matrix();
m.translate(-(bmp.x), -(bmp.y));
m.scale(0.5, 0.5);
p = new Point(0, 0);
blur = new BlurFilter(4, 4, 1);
}
private function setFullScreenQuality(_arg1:FullScreenEvent=null):void{
stage.quality = ((stage.displayState == StageDisplayState.FULL_SCREEN)) ? StageQuality.LOW : StageQuality.HIGH;
}
private function mouseMoveListener(_arg1:MouseEvent):void{
paused = false;
}
private function mouseLeaveListener(_arg1:Event):void{
paused = true;
}
}
}//package com.neave.imagination
Section 3
//NeaveLink (com.neave.link.NeaveLink)
package com.neave.link {
import flash.display.*;
import flash.events.*;
import flash.net.*;
public class NeaveLink {
private var container:DisplayObjectContainer;
private var stage:Stage;
private var onSite:Boolean;
private var canvasWidth:Number;
private var button:NeaveLinkButton;
private var canvasHeight:Number;
public function NeaveLink(_arg1:DisplayObjectContainer, _arg2:Number, _arg3:Number){
this.container = _arg1;
this.stage = _arg1.stage;
this.canvasWidth = _arg2;
this.canvasHeight = _arg3;
onSite = ((((!((stage.loaderInfo.url.indexOf("file:///") == -1))) || (!((stage.loaderInfo.url.indexOf("http://localhost/") == -1))))) || (!((stage.loaderInfo.url.indexOf("http://www.neave.com/") == -1))));
if (onSite){
return;
};
button = new NeaveLinkButton();
button.addEventListener(MouseEvent.CLICK, navigateToNeave);
_arg1.addChild(button);
button.x = (_arg2 / 2);
stage.addEventListener(Event.RESIZE, linkResizeListener);
linkResizeListener();
}
private function linkResizeListener(_arg1:Event=null):void{
button.y = Math.ceil((canvasHeight + (((stage.stageHeight - canvasHeight) - 20) / 2)));
}
private function navigateToNeave(_arg1:MouseEvent):void{
navigateToURL(new URLRequest("http://www.neave.com/"), "_top");
}
public function destroy():void{
if (onSite){
return;
};
stage.removeEventListener(MouseEvent.CLICK, navigateToNeave);
stage.removeEventListener(Event.RESIZE, linkResizeListener);
container.removeChild(button);
button = null;
}
}
}//package com.neave.link
Section 4
//NeaveLinkButton (com.neave.link.NeaveLinkButton)
package com.neave.link {
import flash.display.*;
import flash.text.*;
public class NeaveLinkButton extends SimpleButton {
public function NeaveLinkButton(){
var _local1:TextField;
var _local2:TextFormat;
super();
_local1 = new TextField();
_local1.text = "Made by Paul Neave // www.neave.com";
_local1.autoSize = TextFieldAutoSize.CENTER;
_local1.blendMode = BlendMode.INVERT;
_local2 = new TextFormat("Verdana", 11, 0xFFFFFF);
_local2.align = TextFormatAlign.CENTER;
_local1.setTextFormat(_local2);
_local1.x = (-(_local1.width) / 2);
_local1.y = -(_local1.height);
upState = (overState = (downState = (hitTestState = _local1)));
useHandCursor = true;
}
}
}//package com.neave.link
Section 5
//Main (Main)
package {
import flash.display.*;
import com.neave.imagination.*;
public class Main extends Sprite {
private var imagination:NeaveImagination;
public function Main(){
var _local1:Sprite;
super();
_local1 = new Sprite();
addChild(_local1);
imagination = new NeaveImagination(_local1);
stage.showDefaultContextMenu = false;
}
}
}//package