I wanna Runaway
/**
* Copyright 0xABCDEF ( http://wonderfl.net/user/0xABCDEF )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/7edN
*/
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.filters.DisplacementMapFilter;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.net.URLRequest;
import flash.system.Security;
[SWF(width=400, height=400, backgroundColor=0x000000, frameRate=120)]
public class Runaway extends Sprite {
public function Runaway() {
Wonderfl.capture_delay(30);
Security.loadPolicyFile("http://www.selat.net/hnar/crossdomain.xml");
var i:int;
var so:Sound = new Sound(new URLRequest("http://www.selat.net/hnar/Runaway.mp3"));
var c:SoundChannel = so.play();
stage.addEventListener(Event.ENTER_FRAME,ef);
var s:Shape = new Shape();
var ps:Sprite = new Sprite();
var sa:Array = new Array();
const sw:uint = 400;
const sh:uint = 400;
var bd:BitmapData = new BitmapData(sw,sh,false,0);
var b:Bitmap = new Bitmap(bd);
stage.addChild(b);
const nct:ColorTransform = new ColorTransform(1,1,1,0.2);
var nbd:Array = new Array();
for(i=0;i<10;i++){
nbd[i] = new BitmapData(sw,sh,true);
nbd[i].noise(Math.random()*100000);
nbd[i].colorTransform(nbd[i].rect,nct);
}
const p:Point = new Point();
const bf:BlurFilter = new BlurFilter(8,8,6);
const ct:ColorTransform = new ColorTransform(0.995,0.995,0.995);
var df:DisplacementMapFilter = new DisplacementMapFilter(bd,p,1,1);
var a:Number = 0;
var pa:Array = new Array();
function ef(e:Event):void {
s.graphics.clear();
pa.push({x:sw/2,y:sh/2,a:Math.random()*360,r:c.leftPeak*50,c:(Math.random()*0xFFFFFF)|0x333333});
pa.push({x:sw/2,y:sh/2,a:Math.random()*360,r:c.rightPeak*50,c:(Math.random()*0xFFFFFF)|0x333333});
for(i=0;i<pa.length;i++){
s.graphics.beginFill(pa[i].c);
s.graphics.drawCircle(pa[i].x,pa[i].y,pa[i].r);
s.graphics.endFill();
s.blendMode = "add";
ps.addChild(s);
sa.push(s);
pa[i].x += Point.polar(pa[i].r,pa[i].a).x;
pa[i].y += Point.polar(pa[i].r,pa[i].a).y;
pa[i].r -= 1;
if((pa[i].x>sw)||(pa[i].x<0)||(pa[i].y>sh)||(pa[i].y<0)||(pa[i].r<=0.5)){
ps.removeChild(sa[i]);
pa.splice(i,1);
}
}
a += (Math.random()*4-2)*(c.leftPeak+c.rightPeak);
df.scaleX = Point.polar((c.leftPeak+c.rightPeak)*120,a).x;
df.scaleY = Point.polar((c.leftPeak+c.rightPeak)*120,a).y;
bd.draw(ps);
bd.applyFilter(bd,bd.rect,p,bf);
bd.copyPixels(nbd[Math.floor(Math.random()*10)],bd.rect,p,null,null,true);
bd.applyFilter(bd,bd.rect,p,df);
bd.colorTransform(bd.rect,ct);
}
}
}
}