Active Window Blur

I was checking out a website yesterday when it suddenly reminded me of a Pixelfumes experiment I remembered seeing many moons ago. After finding it with a quick Google search, just for kicks, I decided to play around and update the idea to AS3. I didn’t bother with the constant updating to accomadate video as that seemed a tad processor hungry, but it wouldn’t be difficult to implement at all. What I would rather do with it is make it possible to open several windows at once all masking the same background image. Maybe later on tonight.

Anyway here’s the script for interested parties. An example follows below. Thank you to Pixelfumes for the original idea and AS2 script.

package com.onebyonedesign.extras {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.filters.BlurFilter;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	* Blurs a background (MovieClip or Sprite) behind a transparent window (MovieClip or Sprite).
	* Based on Pixelfumes AS2 class
	* @author Devon O.
	public class WindowBlur {
		private var _background:DisplayObjectContainer;
		private var _window:DisplayObjectContainer;
		private var _blurredImageData:BitmapData;
		private var _blurredImage:Bitmap;
		private var _mask:DisplayObjectContainer;
		private var _blurAmount:int;
		private var _blur:BlurFilter;
		private var _point:Point = new Point();
		 * @param	background		MovieClip or Sprite which will be blurred behind window.
		 * @param	window			(Semi) transparent MovieClip or Sprite behind which will be a blurred background.
		 * @param	blurAmount		The amount of blur to apply to background image.
		 * NOTE: background and window objects *must* be added to display list before instantiating an instance of this class.
		 * TODO: allow multiple window instances with same background.
		 * FLASH BUG: 	If window instance is created programatically, it cannot have filters applied.
		 * 				If window instance is linked to MovieClip in library it CAN have filters applied.
		public function WindowBlur(background:DisplayObjectContainer, window:DisplayObjectContainer, blurAmount:int = 8 ):void {
			_background = background;
			_window = window;
			_blurAmount = (blurAmount >= 0 && blurAmount < = 255) ? blurAmount : 16;
			_blur = new BlurFilter(_blurAmount, _blurAmount, 3);
		private function initBlur():void {
			_blurredImageData = new BitmapData(_background.width, _background.height, false);
			_blurredImageData.applyFilter(_blurredImageData, _blurredImageData.rect, _point, _blur);
			_blurredImage = new Bitmap(_blurredImageData);
		private function initMask():void {
			var MaskClass:Class = Object(_window).constructor;
			_mask = new MaskClass();
			_mask.filters = _window.filters;
			_blurredImage.mask = _mask;
			_mask.visible = false;
			_window.addChildAt(_mask, 0);
		private function update():void {
			_blurredImage.mask = _mask;
		public function kill():void {
			_blurredImage = null;
			_blurredImageData = null;
			_mask = null;
			_blur = null;
		public function get blurAmount():int { return _blurAmount; }
		public function set blurAmount(value:int):void {
			_blurAmount = value;
			_blur.blurX = _blur.blurY = _blurAmount;
} (document class):

package {
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.filters.DropShadowFilter;
	import com.onebyonedesign.extras.WindowBlur;
	import com.onebyonedesign.ui.OBO_ValueSlider;
	import flash.geom.Rectangle;
	import flash.text.AntiAliasType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	* Demonstrates WindowBlur Class
	* @author Devon O.
	public class Main extends Sprite {
		// GraphicWindow is MovieClip in .fla library
		private var _window:GraphicWindow;
		// Background is MovieClip in .fla library
		private var _bg:Background;
		private var _windowBlur:WindowBlur;
		private var _shadow:DropShadowFilter = new DropShadowFilter(2, 90, 0x000000, 1, 2, 2, 1, 3);
		private var _dragBounds:Rectangle;
		public function Main():void {
			// Background is MovieClip in .fla library
			_bg = new Background();
		private function init():void {
		private function initWindow():void {
			// GraphicWindow is MovieClip in library
			_window = new GraphicWindow();
			_window.x = int(stage.stageWidth * .5 - _window.width * .5);
			_window.y = int(stage.stageHeight * .5 - _window.height * .5);
			_window.filters = [_shadow];
			_dragBounds = new Rectangle(0, 0, stage.stageWidth - _window.width, stage.stageHeight - _window.height);
			_window.addEventListener(MouseEvent.MOUSE_DOWN, pressHandler);
		private function initBlur():void {
			_windowBlur = new WindowBlur(_bg, _window);
		private function initControlPanel():void {
			var cp:Sprite = new Sprite();;, 0, 150, 30, 10, 10);;
			cp.filters = [_shadow];
			cp.x = 10;
			cp.y = stage.stageHeight - cp.height - 10;
			var tf:TextField = new TextField();
			var fmt:TextFormat = new TextFormat("_sans", 11);
			tf.defaultTextFormat = fmt;
			tf.autoSize = TextFieldAutoSize.LEFT;
			tf.selectable = false;
			tf.mouseEnabled = false;
			tf.antiAliasType = AntiAliasType.ADVANCED;
			tf.text = "Blur amount:";
			tf.x = 5;
			tf.y = 5;
			var blurSlider:OBO_ValueSlider = new OBO_ValueSlider(tf.textWidth, 0, 64, _windowBlur.blurAmount);
			blurSlider.x = tf.x + tf.textWidth + 8;
			blurSlider.y = 13;
			blurSlider.addEventListener(ValueSliderEvent.DRAG, blurChangeHandler);
		private function blurChangeHandler(event:ValueSliderEvent):void {
			_windowBlur.blurAmount = int(event.value);
		private function pressHandler(event:MouseEvent):void {
			stage.addEventListener(MouseEvent.MOUSE_UP, releaseHandler);
			_window.startDrag(false, _dragBounds);
		private function releaseHandler(event:MouseEvent):void {
			stage.removeEventListener(MouseEvent.MOUSE_UP, releaseHandler);


  1. […] объектов, для их анимации, используя серию картинок. Active Window Blur SWFsize – работает в связке с SWFObject и предоставляет […]

  2. Zik Uralov says:

    Really cool effect. What about to make blur main window, when pop up is activated? Any suggestions are appreciated.

RSS feed for comments on this post. / TrackBack URI

Leave a Reply

Devon O. Wolfgang

Technical Reviewer of “The Essential Guide to Flash CS4 AIR Development”

Contributing Author of “Flash AS3 for Interactive Agencies”

Senior Software Engineer at Meez

Starling Particle Editor


Droste / Escher Effect in AGAL

A New Year’s Eve bonus[…]


Ending the Year with Dynamic Multi-Pass Shaders in Starling

I think there’s some law which states you have to make at least two blog posts per year to legally say you maintain a blog[…]

Adobe ANEs

Base Mobile Tasks .ane and a Few Tips

Admittedly (and rather pathetically), it’s been so long since I’ve posted anything on this blog[…]


Some Photographic Shaders

A couple weeks ago I was contacted and asked to develop some filters for Starling that could be used in a mobile camera app[…]


Animated Particles, Books, and Code – It’s a New Year

It’s a new year[…]


Logical Or Assignment Bug in ASC2

So, here’s something to keep an eye on if switching to AIR 3.8[…]

Starling Filter Collection

Starling Filter Collection

Building up a collection of filters for the Starling framework[…]

Starling Warp

Warp Filter for Starling

Another filter for the Starling framework[…]


Promises Promises

What it boils down to is handling asynchronous tasks […] in a clean, intelligent fashion […]


Starling ‘God Ray’ Filter

While cruising the internet today looking for interesting things to try out I ran across this fun little GPU Gem[…]

Alpha in Starling Filters and Basic Branching in AGAL

In plain English to create a circular mask we would want to do something like this[…]

Starling, Nape Physics, and PhysicsEditor

A look at using the PhysicsEditor tool for Nape and Starling […]

Playing With a Couple Game Ideas

Just a couple game fragments, really[…]

One More Filter For Starling

Another filter for the Starling framework[…]

Filters in Starling

Using and writing filters in the Starling framework[…]

Towards a Better Scratch

Perhaps it was too much Meat Beat Manifesto in the late 80’s […]