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 kuma360 20 Jul 2010
/**
 * Copyright kuma360 ( http://wonderfl.net/user/kuma360 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mMKX
 */

package 
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.filters.BlurFilter;
    import flash.geom.Point;
    import flash.net.URLRequest;
    import flash.system.LoaderContext;
    
    public class Main extends Sprite 
    {
        public function Main():void 
        {
            /////////////////////////////////
            var screen:BitmapData = new BitmapData ( 465 , 465 , false , 0 ) ;
            addChild ( new Bitmap ( screen ) ) ;
            
            /////////////////////////////////
            var B1:BitmapData = null ;
            var B2:BitmapData = null ;
            
            /////////////////////////////////
            var A:Loader = new Loader ( ) ;
            A.contentLoaderInfo.addEventListener (
                Event.COMPLETE , 
                function ( e:Event ) :void {
                    
                    //がぞうこぴー
                    B1 = new BitmapData ( 465 , 465 , false , 0 ) ;
                    B1.draw ( A ) ;
                    
                    //にちか 
                    //20100720 thresholdの使い方が間違ってたので修正
                    var T0:BitmapData = B1.clone();
                    T0.threshold ( T0 , T0.rect , new Point , "<" , 0xB000 , 0 , 0xFF00 , true ) ;
                    
                    //ぼかす
                    var T1:Bitmap = new Bitmap ( T0 ) ;
                    T1.filters = [ new BlurFilter ( 50 , 50 , 2 ) ] ;
                    
                    //フィルタ確認用
                    B2 = new BitmapData ( 465 , 465 , false , 0 ) ;
                    B2.draw ( T1 ) ;
                    
                    //加算で合成
                    B1.draw ( T1 , null , null , "add" ) ;
                    screen.copyPixels ( B1 , B1.rect , new Point ) ;
                    
                }
            ) ;
            
            //フィルターだけ見る
            stage.addEventListener (
                MouseEvent.MOUSE_DOWN ,
                function ():void {
                    screen.fillRect ( screen.rect , 0x000000 ) ;
                    screen.copyPixels ( B2 , B2.rect , new Point ) ;
                }
            ) ;
            
            //全部見る
            stage.addEventListener (
                MouseEvent.MOUSE_UP,
                function ( ) :void {
                    screen.fillRect ( screen.rect , 0x000000 ) ;
                    screen.copyPixels ( B1 , B1.rect , new Point ) ;
                }
            ) ;
            
            
            /////////////////////////////////
            A.load (
                new URLRequest ( "http://moringo.moo.jp/out/b01.jpg" ) ,
                new LoaderContext ( true )
            ) ;
            
        }
        
    }
    
}