저해상도 RGB모니터효과 플래시.


- 순서

1. 플래시

2. 미리보기

3. 소스코드




1. 플래시






2. 미리보기













3. 소스코드


package  {
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import flash.display.MovieClip;
	import flash.net.FileReference;
	import flash.net.FileFilter;
	import flash.events.Event;
	import flash.utils.ByteArray;
	import flash.display.Loader;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.display.DisplayObjectContainer;	
	
	public class TVeffect extends MovieClip{
		
		public function TVeffect() {
			
			var file:FileReference = new FileReference();
			file.addEventListener(Event.SELECT,onSelected);
			var loadedBytes:ByteArray;
			var image:Loader = new Loader();
			var container:MovieClip = new MovieClip();
			
			var tf1:TextField = new TextField();
			tf1.autoSize = TextFieldAutoSize.LEFT;
			tf1.x = tf1.y = 200;
			tf1.text = "화면을 눌러서 그림파일을 선택하세요.";
			addChild(tf1);
			var tf2:TextField = new TextField();
			tf2.autoSize = TextFieldAutoSize.LEFT;
			tf2.x = tf2.y = 450;
			tf2.text = "http://tibyte.kr";
			addChild(tf2);
			addChild(container);
			
			stage.addEventListener(MouseEvent.CLICK, onClick);
			function onClick(evt:MouseEvent):void
			{
				file.browse([new FileFilter("image file (JPG, JPEG, GIF, PNG)","*.jpg;*.jpeg;*.gif;*.png")]);
			}
			function onSelected(evt:Event):void
			{
				evt.target.load();
				evt.target.addEventListener(Event.COMPLETE, onCompleted);
			
			}
			
			function onCompleted(evt:Event):void
			{
				loadedBytes = evt.target.data;
				image.contentLoaderInfo.addEventListener(Event.INIT,onInited);
				image.loadBytes(loadedBytes);
			}
			
			
			function onInited(evt:Event):void
			{
				removeChildAll(container);
				var bmp:Bitmap = evt.target.content as Bitmap;
				container.addChild(bmp);
				for(var i_x:int = 0; i_x<bmp.bitmapData.width; i_x++){
					for(var i_y:int = 0; i_y<bmp.bitmapData.height; i_y++) {
						bmp.bitmapData.setPixel(i_x,i_y,bmp.bitmapData.getPixel(i_x,i_y)&0x0000ff<<(i_x%3)*8);
					}
				}
			}
			
			function removeChildAll(container:DisplayObjectContainer):void
			{
				for(var i:int=0; i<container.numChildren; i++) {
					container.removeChildAt(i);
				}
			}
				
		}
	
	}
	
}

 







+ Recent posts