In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

THE BEST VIDEO GRID

THE BEST VIDEO GRID.
Color grid overlayed.
Author:Hugo Campodonico. (vectorcinco)
Get Adobe Flash player
by vectorcinco 24 Oct 2009
/**
 * Copyright vectorcinco ( http://wonderfl.net/user/vectorcinco )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/zx50
 */

/*
 THE BEST VIDEO GRID.
 Color grid overlayed.
 Author:Hugo Campodonico. (vectorcinco)
*/
package {
	import flash.display.*;
	import flash.media.*;
	import flash.events.*;

	public class Main extends Sprite {
		var video:Video;
		var camera:Camera;

		function Main() {
			stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
			
			camera=Camera.getCamera();
			if (camera!=null) {
				camera.setMode(stage.stageWidth, stage.stageHeight,15);
				camera.setMotionLevel(10);
				camera.setQuality(0,50);
				video=new Video(camera.width,camera.height);
				video.attachCamera(camera);
				addChild(video);
				
			}
			createBg();
		}
		public function background():BitmapData {
			return BitmapPatternBuilder.build( 
			                [[0, 1], 
			                [2, 3]],
			                [0xFFFF0000, 0xff00FF00, 0xff0000FF, 0xff000000] 
			            );
		}
		private function createBg():void {
			var pattern:BitmapData=background();
			var bg:Sprite = addChild(new Sprite()) as Sprite;
			bg.graphics.beginBitmapFill(pattern);
			bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
			bg.graphics.endFill();
			bg.blendMode="overlay";
		}
	}
}
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Graphics;

class BitmapPatternBuilder {
	public static function build(pattern:Array, colors:Array):BitmapData {
		var bitmapW:int=pattern[0].length;
		var bitmapH:int=pattern.length;
		var bmd:BitmapData=new BitmapData(bitmapW,bitmapH,true,0x000000);
		for (var yy:int=0; yy<bitmapH; yy++) {
			for (var xx:int=0; xx<bitmapW; xx++) {
				var color:int=colors[pattern[yy][xx]];
				bmd.setPixel32(xx, yy, color);
			}
		}
		return bmd;
	}

	public static function beginBitmapFill(pattern:Array, colors:Array, graphics:Graphics):void {
		var bmd:BitmapData=build(pattern,colors);
		graphics.beginBitmapFill(bmd);
		bmd.dispose();
	}
}