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

シェーダバイトコードとかいうやつ

Get Adobe Flash player
by darman 21 Dec 2009
    Embed
/**
 * Copyright darman ( http://wonderfl.net/user/darman )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/hyNp
 */

package {
	import flash.events.*;
	import flash.display.*;
	import flash.net.*;
	import flash.text.*;
	import flash.utils.*;
	import flash.system.*;
	import flash.geom.*;
	import flash.filters.*;
	import flash.ui.*;
		
    public class FlashTest extends Sprite
    {
    		private var sp:Sprite = new Sprite();
    		
        public function FlashTest() {
            // write as3 code here..
            
            init();
        }
        
        private function init():void
        {
        		sp.graphics.beginFill(0x000000);
        		sp.graphics.drawRect(0,0,400,400);
        		sp.graphics.endFill();
        		addChild(sp);
        		
	        var binary : ByteArray = CustomFilterGetByteArray();
		
			// シェーダ作成
			var shader:Shader = new Shader();
			shader.byteCode = binary;
			var filter:ShaderFilter = new ShaderFilter(shader); 
			
			// パラメータアクセス用
			var data : ShaderData  = shader.data;
			var param : ShaderParameter;
			
			// パラメータ
			var phase:Number = 0;		// 位相
			var amplitude:Number = 20// 振幅
			var cycle:Number = 100;	// 周期
			
			addEventListener(Event.ENTER_FRAME,function(e:Event):void{
				
				// 位相を変化
				phase += 0.01;
				if(phase > 1)	phase -= 1;
				// 位置
				param = data.position;
				param.value = [mouseX,mouseY];
				// 位相
				param = data.phase;
				param.value = [phase];
				// 振幅
				param = data.amplitude;
				param.value = [amplitude];
				// 周期
				param = data.cycle;
				param.value = [cycle];
				// 適応
				sp.filters = [filter];
			});
        }
        
       private function CustomFilterGetByteArray():ByteArray
       {
			var a:ByteArray = new ByteArray();
			var f:Function;
			
			f = a.writeUnsignedInt;
			f(0xa5010000); f(0x00a41600); f(0x43697263); f(0x6c655761); 
			f(0x76654369); f(0x72636c65); f(0x46696c74); f(0x6572a00c); 
			f(0x6e616d65); f(0x73706163); f(0x65006375); f(0x72766520); 
			f(0x77617665); f(0x20636972); f(0x636c6500); f(0xa00c7665); 
			f(0x6e646f72); f(0x0048616b); f(0x7568696e); f(0x00a00876); 
			f(0x65727369); f(0x6f6e0001); f(0x00a00c64); f(0x65736372); 
			f(0x69707469); f(0x6f6e0089); f(0x7e8ff382); f(0xc9835483); 
			f(0x43839383); f(0x4a815b83); f(0x7582c590); f(0x4c8f6b82); 
			f(0xb782e983); f(0x74834283); f(0x8b835e00); f(0xa1010200); 
			f(0x000c5f4f); f(0x7574436f); f(0x6f726400); f(0xa3000473); 
			f(0x726300a1); f(0x02040100); f(0x0f647374); f(0x00a10102); 
			f(0x00000370); f(0x6f736974); f(0x696f6e00); f(0xa2026465); 
			f(0x6661756c); f(0x7456616c); f(0x75650000); f(0x00000000); 
			f(0x000000a2); f(0x0c646573); f(0x63726970); f(0x74696f6e); 
			f(0x00897e82); f(0xcc928690); f(0x538dc095); f(0x5700a101); 
			f(0x01020008); f(0x6379636c); f(0x6500a201); f(0x6d696e56); 
			f(0x616c7565); f(0x003f8000); f(0x00a20164); f(0x65666175); 
			f(0x6c745661); f(0x6c756500); f(0x42c80000); f(0xa20c6465); 
			f(0x73637269); f(0x7074696f); f(0x6e009467); f(0x82aa88ea); 
			f(0x8efc82b7); f(0x82e992b7); f(0x82b300a1); f(0x01010200); 
			f(0x04706861); f(0x736500a2); f(0x016d696e); f(0x56616c75); 
			f(0x65000000); f(0x0000a201); f(0x6d617856); f(0x616c7565); 
			f(0x003f8000); f(0x00a20164); f(0x65666175); f(0x6c745661); 
			f(0x6c756500); f(0x00000000); f(0xa20c6465); f(0x73637269); 
			f(0x7074696f); f(0x6e009467); f(0x82cc88ca); f(0x918a00a1); 
			f(0x01010200); f(0x02616d70); f(0x6c697475); f(0x646500a2); 
			f(0x016d696e); f(0x56616c75); f(0x65000000); f(0x0000a201); 
			f(0x64656661); f(0x756c7456); f(0x616c7565); f(0x00412000); 
			f(0x00a20c64); f(0x65736372); f(0x69707469); f(0x6f6e0094); 
			f(0x6782cc97); f(0x6882ea95); f(0x9d001d03); f(0x00c10000); 
			f(0x10001d02); f(0x00100000); f(0x80000202); f(0x00100300); 
			f(0x00001d03); f(0x00200200); f(0xc0001d02); f(0x00100000); 
			f(0xc0000202); f(0x00100300); f(0x40001d03); f(0x00100200); 
			f(0xc0001d04); f(0x00c10300); f(0xb0001d02); f(0x00100400); 
			f(0x40000602); f(0x00100400); f(0x00001d03); f(0x00200200); 
			f(0xc0001d02); f(0x00100400); f(0x00000302); f(0x00100400); 
			f(0x00001d03); f(0x00100400); f(0x40000303); f(0x00100400); 
			f(0x40001d04); f(0x00200200); f(0xc0000104); f(0x00200300); 
			f(0xc0001602); f(0x00100400); f(0x80001d03); f(0x00100200); 
			f(0xc0000402); f(0x00100200); f(0x00000302); f(0x00100300); 
			f(0xc0001d04); f(0x00200200); f(0xc0001a02); f(0x00100400); 
			f(0x80001d04); f(0x00100400); f(0x80000204); f(0x00100200); 
			f(0xc0001d04); f(0x00200400); f(0xc0001d02); f(0x00100400); 
			f(0x80000102); f(0x00100200); f(0x40003204); f(0x001043b4); 
			f(0x00001d05); f(0x00800200); f(0xc0000305); f(0x00800400); 
			f(0xc0003202); f(0x00103c8e); f(0xfa350302); f(0x00100500); 
			f(0x00000c04); f(0x00100200); f(0xc0001d02); f(0x00100400); 
			f(0xc0000302); f(0x00100200); f(0x80001d03); f(0x00100200); 
			f(0xc0000d02); f(0x00100300); f(0x80001d04); f(0x00100200); 
			f(0xc0000304); f(0x00100300); f(0xc0000103); f(0x00800400); 
			f(0xc0000c02); f(0x00100300); f(0x80001d04); f(0x00100200); 
			f(0xc0000304); f(0x00100300); f(0xc0000103); f(0x00400400); 
			f(0xc0003105); f(0x00f10300); f(0x10001d01); f(0x00f30500); 
			
			f = a.writeShort;
			f(0x1b00); 
			
			return a;
		}
        
        
    }
}