Virgin PixelBender, on the rocks
BradSedito 2011
Forked from 'otherone'
/**
* Copyright bradsedito ( http://wonderfl.net/user/bradsedito )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/d9F4
*/
// BradSedito 2011
// Forked from 'otherone'
package
{
import flash.display.AVM1Movie;
import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.display.Sprite;
import flash.geom.Transform;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.system.LoaderContext;
import com.bit101.components.InputText;
import com.bit101.components.PushButton;
import net.hires.debug.Stats;
[SWF(frameRate = 24,backgroundColor = 0x000000)]
public class VirginPB extends MovieClip
{
private const STW:uint = stage.stageWidth;
private const STH:uint = stage.stageHeight;
public var stats:Stats = new Stats();
private var _mc:MovieClip = new MovieClip();
private var button:PushButton;
private var BlurLength:Number;
private var BlurAlpha:Number;
private var trans:Transform;
private var color:ColorTransform;
private var solidColor:uint = new uint( 0xCCCCCC );
public function VirginPB()
{
// Add Stats component to stage:
addChild( stats );
var url:String = "http://a0.twimg.com/profile_images/1389298946/me_photo_cold_flash.png";
var context:LoaderContext = new LoaderContext(true);
var _loader:Loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
_loader.load(new URLRequest(url), context);
function completeHandler(event : Event):void
{
_mc.addChild(_loader);
addChild(_mc);
_mc.x=STW/2-_mc.width/2;
_mc.y=STH/2-_mc.height/2;
init();
}
}
private function init():void
{
var SOURCE_MOVIECLIP:MovieClip = _mc;
var mcx:Number = SOURCE_MOVIECLIP.x;
var mcy:Number = SOURCE_MOVIECLIP.y;
var mcw:Number = SOURCE_MOVIECLIP.width;
var mch:Number = SOURCE_MOVIECLIP.height;
var BlurRect:Object =
{
x:-mcw/2,
y:-mch/2,
w:mcw*2+mcw/2,
h:mch*2+mch/2
};
addEventListener( Event.ENTER_FRAME,enterFrameHandler );
BlurLength = 1.003;
BlurAlpha = 0.9;
var bmpData:BitmapData = new flash.display.BitmapData(BlurRect.w, BlurRect.h,
true, 0x00FFFFFF);
var bmpBuffer:BitmapData = new flash.display.BitmapData(BlurRect.w, BlurRect.h,
true, 0x00FFFFFF);
var render:MovieClip =new MovieClip();
SOURCE_MOVIECLIP.addChild(render);
render.x = BlurRect.x;
render.y = BlurRect.y;
trans = new flash.geom.Transform(render);
color = new flash.geom.ColorTransform(
1, 1, 1, BlurAlpha, 0, 0, 0, 0);
trans.colorTransform = color;
function enterFrameHandler(event:Event):void
{
bmpData.copyPixels(
bmpBuffer, new flash.geom.Rectangle(0, 0, BlurRect.w, BlurRect.h), new flash.geom.Point(0, 0)
);
var m:Matrix = new flash.geom.Matrix( 1 , 0, 0, 1,-BlurRect.x, -BlurRect.y );
bmpBuffer.fillRect(new flash.geom.Rectangle(
0, 0, BlurRect.w, BlurRect.h), 0x00FFFFFF);
bmpBuffer.draw(SOURCE_MOVIECLIP, m);
m = new flash.geom.Matrix(1,0,0,1,0,0);
m.translate(-mouseX,-mouseY);
m.scale(BlurLength,BlurLength);
m.translate(mouseX,mouseY);
render.graphics.clear();
render.graphics.beginBitmapFill(bmpData, m, true, true);
render.graphics.moveTo(0, 0);
render.graphics.lineTo(0, BlurRect.h);
render.graphics.lineTo(BlurRect.w, BlurRect.h);
render.graphics.lineTo(BlurRect.w, 0);
render.graphics.endFill();
}
}
}
}
// Discarded Code from the forking:
/*
button = new PushButton(this,0,0,"クリックしてね",onMouseClick);
button.x=STW-button.width-2;
button.y=STH-button.height-2;
function onMouseClick(e:Event):void
{
BlurLength = 1.001;
BlurAlpha = 0.9;
//trans = new flash.geom.Transform(render);
color = new flash.geom.ColorTransform(
-1, 1, 1, BlurAlpha, 0, 0, 0, 0);
trans.colorTransform = color;
}
*/