forked from: Chapter 36 Example 14

by Aksor.Al forked from Chapter 36 Example 14 (diff: 3)
♥0 | Line 37 | Modified 2011-01-04 09:26:49 | MIT License
play

ActionScript3 source code

/**
 * Copyright Aksor.Al ( http://wonderfl.net/user/Aksor.Al )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/32qf
 */

// forked from actionscriptbible's Chapter 36 Example 14
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="2", 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://www.promocionarte.info/APPS/aksoral/app_full_proxy.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;
    }
  }
}