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

forked from: Noize

**********************************************  
code by yonedashigeru  
http://wab.cc/  
**********************************************
Get Adobe Flash player
by mitien 23 Jul 2010
// forked from yonedashigeru's Noize
//**********************************************  
// 
// code by yonedashigeru  
//  
// http://wab.cc/  
//  
//**********************************************  

package {

    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.utils.*;
    import flash.text.*;
    
    import flash.filters.*;
    import caurina.transitions.Tweener;
        
    public class Main extends Sprite{
        
        public var cover_sp:Sprite;
        
        private var r_bmd:BitmapData;
        private var r_bm:Bitmap;
        private var g_bmd:BitmapData;
        private var g_bm:Bitmap;
        private var b_bmd:BitmapData;
        private var b_bm:Bitmap;
        
        private var target:TextField;
        private var mod:String;
        
        private var noise_map:Array;
        private var map_num:int = 3;
        private var dfil:DisplacementMapFilter;
        
        
        public var delay:Number = 100;
        
        
        /*======================================================================*//**
        * コンストラクタ
        */
        public function Main() 
        {
            
            target = new TextField();
                        target.text = "mitien";
            
            var _tf:TextFormat = new TextFormat();
            _tf.size = 100;
            _tf.color = 0x000000;
            target.setTextFormat(_tf);
            
            
            target.autoSize = TextFieldAutoSize.LEFT;
            mod = BlendMode.DARKEN;
            

            var tmp_w:Number = target.width;
            var tmp_h:Number = target.height;
            
            
            r_bmd = new BitmapData(tmp_w, tmp_h, true, 0);
            r_bmd.draw(target, null, null, null, null, true);
            r_bm = new Bitmap(r_bmd);
            r_bm.transform.colorTransform = new ColorTransform(1, 1, 1, 1, 0, 255, 255, 0);
            r_bm.blendMode = mod;
            
            g_bmd = new BitmapData(tmp_w, tmp_h, true, 0);
            g_bmd.draw(target, null, null, null, null, true);
            g_bm = new Bitmap(g_bmd);
            g_bm.transform.colorTransform = new ColorTransform(1, 1, 1, 1, 255, 0, 255, 0);
            g_bm.blendMode = mod;
            
            b_bmd = new BitmapData(tmp_w, tmp_h, true, 0);
            b_bmd.draw(target, null, null, null, null, true);
            b_bm = new Bitmap(b_bmd);
            b_bm.transform.colorTransform = new ColorTransform(1, 1, 1, 1, 255, 255, 0, 0);
            b_bm.blendMode = mod;
            
            
            cover_sp = new Sprite();
            cover_sp.addChild(r_bm);
            cover_sp.addChild(g_bm);
            cover_sp.addChild(b_bm);
                        cover_sp.x = (stage.stageWidth - cover_sp.width) / 2;
                        cover_sp.y = (stage.stageHeight - cover_sp.height) / 2;
            addChild(cover_sp);
            
            start();
        }
        /*======================================================================*//**
        * start
        */
        public function start():void
        {
                
            createNoise();
            
            dfil = new DisplacementMapFilter(null, new Point(0,0), BitmapDataChannel.RED, BitmapDataChannel.RED, 3, 0);
            cover_sp.filters = [dfil];
            
            cover_sp.addEventListener(Event.ENTER_FRAME, onEnter);
            
        }
        
        private var tm_index:int = 0;
        
        /*======================================================================*//**
        * onEnter
        */
        private function onEnter(e:Event) :void
        {
            var tmp_fill:DisplacementMapFilter = cover_sp.filters[0];
            
            var tmp_num:int = Math.floor(Math.random() * noise_map.length);
            tmp_fill.mapBitmap = noise_map[tmp_num];
            cover_sp.filters = [tmp_fill];
            
            r_bm.x = Math.random() * 10 - 5;
            g_bm.x = Math.random() * 10 - 5;
            b_bm.x = Math.random() * 10 - 5;
        }
        /*======================================================================*//**
        * createNoise
        */
        private function createNoise() :void
        {
            noise_map = new Array();
            
            for(var i:int=0; i<map_num; i++)
            {
                var tmp_bmd:BitmapData = new BitmapData(target.width, target.height, false, 0x808080);
                tmp_bmd.noise(Math.floor(Math.random() * 10), 0, 255, 7, true);
                for(var j:int=0; j<tmp_bmd.width; j++)
                {
                    tmp_bmd.scroll(1, 0);
                }
                
                noise_map.push(tmp_bmd);
            }
            
        }
    }
}