Chapter 36 Example 14
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/1Kft
*/
package {
import flash.display.*;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.net.URLRequest;
import flash.system.LoaderContext;
[SWF(frameRate="24", backgroundColor="#000000")]
public class ch36ex14 extends Sprite {
protected var bmp:BitmapData;
protected var seed:int;
protected var image:Loader;
public function ch36ex14() {
image = new Loader();
addChild(image);
image.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad);
image.load(
new URLRequest("http://actionscriptbible.com/files/caviar.jpg"),
new LoaderContext(true)
);
}
protected function onLoad(event:Event):void {
var src:BitmapData = Bitmap(image.content).bitmapData;
bmp = new BitmapData(src.width, src.height, true);
var bitmap:Bitmap = new Bitmap(bmp);
addChild(bitmap);
bitmap.blendMode = BlendMode.MULTIPLY;
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
protected function onEnterFrame(event:Event):void {
bmp.fillRect(bmp.rect, 0);
bmp.noise(++seed, 200, 255, BitmapDataChannel.BLUE, true);
bmp.applyFilter(bmp, bmp.rect, new Point(), new BlurFilter(4, 4, 2));
image.alpha = (seed % 2)? 0.95 : 1;
}
}
}