The Pond
/**
* Copyright jamasian ( http://wonderfl.net/user/jamasian )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/p41h
*/
package
{
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.text.TextField;
import flash.events.ProgressEvent;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.Sprite;
public class thePond extends Sprite
{
private var koi:Sprite = new Sprite();
private var dest:Point = new Point(465/2, 465/2);
private var process:Process = new Process();
private var DLloader:Loader = new Loader();
private var downloads:Array = new Array();
private var urls:Array = new Array();
private var DLpercent:int = 0;
private var DLblock:int;
private var fadeDone:Boolean = false;
private var debug:TextField = debugger();
public function thePond():void { onLoad(); }
public function onLoad():void
{
addChild(process.parent());
//locate("http://fc08.deviantart.net/fs23/f/2007/330/3/1/Bamboo_Zen_by_MissNysha.jpg");
//locate("http://fineartamerica.com/images-small/black-koi-fish-with-konji-devaron-jeffery.jpg");
//locate("http://www.almerekoi.nl/images/koi-types2.jpg");
locate("https://sites.google.com/site/webkychan/home/files/bg.jpg");
locate("https://sites.google.com/site/webkychan/home/files/fg.jpg");
locate("https://sites.google.com/site/webkychan/home/files/head.jpg");
locate("https://sites.google.com/site/webkychan/home/files/1.jpg");
locate("https://sites.google.com/site/webkychan/home/files/2.jpg");
locate("https://sites.google.com/site/webkychan/home/files/3.jpg");
locate("https://sites.google.com/site/webkychan/home/files/4.jpg");
locate("https://sites.google.com/site/webkychan/home/files/5.jpg");
locate("https://sites.google.com/site/webkychan/home/files/6.jpg");
locate("https://sites.google.com/site/webkychan/home/files/7.jpg");
locate("https://sites.google.com/site/webkychan/home/files/tail.jpg");
startDownload();
}
public function onBegin():void
{
fadeOut(process.parent());
}
public function onBuild():void
{
var bg:Sprite = downloads.pop();
var fg:Sprite = downloads.pop();
var head:Sprite = downloads.pop();
var f1:Sprite = downloads.pop();
var f2:Sprite = downloads.pop();
var f3:Sprite = downloads.pop();
var f4:Sprite = downloads.pop();
var f5:Sprite = downloads.pop();
var f6:Sprite = downloads.pop();
var f7:Sprite = downloads.pop();
var tail:Sprite = downloads.pop();
downloads=null;
addChild(head);
head.x=204; head.y=240;
addChild(f1);
f1.x=230; f1.y=230;
addChild(f2);
f2.x=230; f2.y=220;
addChild(f3);
f3.x=230; f3.y=210;
addChild(f4);
f4.x=230; f4.y=200;
addChild(f5);
f5.x=230; f5.y=190;
addChild(f6);
f6.x=230; f6.y=180;
addChild(f7);
f7.x=230; f7.y=170;
addChild(tail);
tail.x=242; tail.y=117;
stage.addEventListener(Event.ENTER_FRAME, onRun);
}
public function onRun():void
{
}
/*
//load bg
addChild(new Bitmap(new BitmapData(465,465,false, 0x222288)));
//load image
var loader:Loader = new Loader();
loader.load(new URLRequest(url));
//store in var koi
addChild(koi);
koi.addChild(loader);
koi.x=Math.random()*350;
koi.y=Math.random()*350;
koi.rotation=20;
stage.addEventListener(Event.ENTER_FRAME, onRun);
}
public function onRun(evt:Event):void
{
var e:Point = new Point();
var dir:int,getX:int,getY:int;
e.x = koi.x+koi.width/2;
e.y = koi.y+koi.height/2;
dir = Math.atan2(dest.y, dest.x)*180/Math.PI;
getX = Math.cos(dir*Math.PI/180)*2;
getY = Math.sin(dir*Math.PI/180)*2;
if (e.x>dest.x-40 && e.x<dest.x+40 && e.y>dest.y-40 && e.y<dest.y+40)
{
dest=new Point(Math.random()*465, Math.random()*465);
}
koi.x+=(e.x<dest.x)? getX : -getX;
koi.y+=(e.y<dest.y)? getY : -getY;
//var t:Matrix = new Matrix(0.3, 1, 1, 0, koi.x, koi.y);
//koi.transform.matrix = t;
var r:int = Math.atan2(dest.y-e.y, dest.x-e.x)*180/Math.PI;
r = (e.y>dest.y)? Math.atan2(e.y-dest.y, e.x-dest.x)*180/Math.PI : r;
koi.rotation += r;
}
*/
/* The following functions are used to download images. */
private function locate(url:String):void
{
urls.push(url);
}
private function startDownload():void
{
DLblock = Math.ceil( 100 / urls.length );
downloadFile();
}
private function downloadFile():void
{
DLloader = new Loader();
DLloader.load( new URLRequest(urls.pop()) );
DLloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, downloadProgress);
}
private function downloadProgress(e:ProgressEvent):void
{
var DLloaded:Number = Math.ceil( e.bytesLoaded / e.bytesTotal );
process.set(DLpercent + (DLloaded) * DLblock);
if (DLloaded==1) DLloader.contentLoaderInfo.addEventListener(Event.COMPLETE, downloadComplete);
}
private function downloadComplete(e:Event):void
{
DLloader.contentLoaderInfo.removeEventListener(Event.COMPLETE, downloadComplete);
DLloader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, downloadProgress);
//store in sprite
var s:Sprite = new Sprite();
s.addChild(DLloader);
downloads.push(s);
DLpercent+=Math.ceil( 100 / urls.length );
if (urls.length>0)
{
downloadFile();
}else{
onBegin();
}
}
private function fadeOut(a:Sprite):void
{
var fade:Sprite = new Sprite();
fade.graphics.beginFill(0xFFFFFF);
fade.graphics.drawRect(0, 0, 465, 465);
fade.alpha=0;
addChild(fade);
var timer:Timer = new Timer(50, 20);
timer.start();
fadeDone=false;
timer.addEventListener(TimerEvent.TIMER, function(e:TimerEvent):void
{
setChildIndex(fade, numChildren-1);
fade.alpha+=0.05;
});
timer.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:TimerEvent):void
{
removeChild(fade);
removeChild(a);
timer.stop();
timer=null;
fadeDone=true;
onBuild();
});
}
private function debugger():TextField
{
/*
creates a textfield for debugging (mainframe).
*/
var mainframe:TextField = new TextField();
mainframe.x = 10;
mainframe.y = 460-200;
mainframe.width = 460;
mainframe.height = 200;
mainframe.textColor = 0x000000;
mainframe.selectable = false;
addChild(mainframe);
return mainframe;
}
}
}
import flash.display.Sprite;
import flash.events.Event;
class Simulator
{
public function Simulator(e:Sprite, xDif:int, yDif:int, follow:Boolean=true):void
{
e.addEventListener(Event.ENTER_FRAME, function():void
{
//if ()
});
}
}
import flash.text.TextField;
import flash.display.Sprite;
import flash.display.Shape;
import flash.events.Event;
class Process
{
private var e:Sprite = new Sprite();
private var bg:Shape = new Shape();
private var ld:Shape = new Shape();
private var fg:Shape = new Shape();
private var s:TextField = new TextField();
private var wave:int = 1;
private var size:int = 300;
private var percent:int = 0;
public function Process()
{
bg.graphics.beginFill(0x000000);
ld.graphics.beginFill(0x3399CC);
fg.graphics.beginFill(0xFFFFFF);
bg.graphics.drawRect(0, 0, 465, 465);
ld.graphics.drawRect(0, 0, size, size);
ld.x=(465-size)/2;
fg.graphics.drawRect(2, 2, 461, 461);
fg.graphics.drawCircle((465)/2, (465)/2, (size/2));
s.text = "0%";
s.x = (465-s.width )/2;
s.y = (465-10)/2;
s.autoSize = "center";
s.textColor= 0xFFFFFF;
e.addChild(bg);
e.addChild(ld);
e.addChild(fg);
e.addChild(s);
set(0);
}
public function parent():Sprite
{
return e;
}
public function set(i:int):void
{
i=(i>100)? 100 : i;
ld.scaleY=(i/100);
ld.y=(465/2) + (size/2) -ld.height;
percent=i;
s.text=percent + "%";
}
public function get():int
{
return percent;
}
}