Glitch 2
Glitch 2
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/zxlg
*/
/*
Glitch 2
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="#000", 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://2.bp.blogspot.com/_McL0_OWcuUs/SxgL5FbzJlI/AAAAAAAAAFw/oGFmUWu7g9o/s400/pulp-32-565x581.jpg"));
display = new Loader();
display.contentLoaderInfo.addEventListener(Event.COMPLETE, glitchDone);
addChild(display);
display.scaleX = 1.2;
display.scaleY = 1.2;
}
protected function glitchDone(event:Event):void
{
setTimeout(loop, 300);
}
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);
}
}
}