package  {
	import flash.net.URLRequest;
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.geom.Rectangle;
	import flash.events.Event;
	import flash.geom.ColorTransform;
	
	public class RuntimeBitmap extends Sprite{

		private var _loader:Loader;
			
		public function RuntimeBitmap() {
			_loader = new Loader ();
			_loader.load(new URLRequest("image2.jpg"));
			_loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);			
		}
		private function completeHandler(event:Event):void {
			var w:Number = _loader.width;
			var h:Number = _loader.height;
			var bitmapData:BitmapData = new BitmapData(w,h);
			bitmapData.draw(_loader);
			bitmapData.colorTransform(new Rectangle(0,0,w/2,h/2),new ColorTransform(1,0,0,1,0,0,0,0));
			bitmapData.colorTransform(new Rectangle(w/2,0,w/2,h/2),new ColorTransform(0,1,0,1,0,0,0,0));
			bitmapData.colorTransform(new Rectangle(0,h/2,w/2,h/2),new ColorTransform(0,0,1,1,0,0,0));
			bitmapData.colorTransform(new Rectangle(w/2,h/2,w/2,h/2),new ColorTransform(1,1,0,1,0,0,0,0));
			
			var bitmap:Bitmap = new Bitmap (bitmapData);
			bitmap.x = 50;
			bitmap.y = 100;
			addChild(bitmap);
		}

	}
	
}
