Glitch
Glitch
By: Ctrl
/**
* Copyright Ctrl ( http://wonderfl.net/user/Ctrl )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/2kci
*/
/*
Glitch
By: Ctrl
2009
*/
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.*;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.utils.*;
[SWF(backgroundColor="#0", frameRate="60")]
public class Glitch extends Sprite
{
private const HEADER:int = 6666;
private var data:ByteArray;
private var origin:ByteArray;
private var display:Loader;
public function Glitch()
{
stage.align = "TL";
stage.scaleMode = "noScale";
var loader:URLLoader = new URLLoader();
loader.dataFormat = "binary";
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest("http://1.bp.blogspot.com/_McL0_OWcuUs/SxgDqO96y3I/AAAAAAAAAFY/cpbxb2hfFNQ/s1600/pulp_1-565x581.jpg"));
display = new Loader();
display.contentLoaderInfo.addEventListener(Event.COMPLETE, glitchDone);
addChild(display);
display.scaleX = .8;
display.scaleY = .8;
}
protected function glitchDone(event:Event):void
{
setTimeout(loop, 500);
}
private function onComplete(e:Event):void {
origin = e.target.data;
data = new ByteArray();
data.writeBytes(origin);
loop(null);
}
private function loop(e:Event = null):void {
var t:int = Math.floor(12);
for(var i:int = 0; i < t; i++)
{
data.position = Math.floor((data.length - HEADER) * Math.random()) + HEADER;
data.writeByte(0);
}
display.loadBytes(data);
}
}
}