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

sketch_08121803

// write as3 code here..
package{
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.filters.DisplacementMapFilter;
    import flash.filters.BlurFilter;
    import flash.display.BitmapDataChannel;
    import flash.geom.Point;
    import flash.text.TextFieldAutoSize;
    import flash.geom.ColorTransform;  
    import flash.geom.Rectangle; 
    import flash.geom.Point;
    import flash.events.Event;

    public class Main extends MovieClip{
        //465x465
		
        private var _tf:TextField;
        private var container:Sprite;

        private var _speed:Number = 2;
        private var _scale:Number = 20;
        private var _octave:uint = 3;
        private var _rndSeed:int = Math.floor(Math.random() * 65536);
        private var _ofsAry:Array;
        private var _spdAry:Array;
        private var fl_disp:DisplacementMapFilter;

        private var seed:Number = Math.floor(Math.random() * 10);
        private var channels:uint = BitmapDataChannel.RED | BitmapDataChannel.BLUE;
        private var _bmd:BitmapData;
		
        private var drawBox:Sprite;
		
        private var _bg:BitmapData;
        private var _bgBmp:Bitmap;
		
        private var tonedown:ColorTransform;  
        private var rect:Rectangle; 
        private var pt:Point;
		
        private var fl_blur:BlurFilter;

        public function Main(){
			
            drawBox = new Sprite();
			
			
            _tf = new TextField();
            _tf.autoSize = TextFieldAutoSize.LEFT;
            _tf.textColor = 0x110101;
            _tf.text = "わんだふる";
            _tf.x = -(_tf.textWidth + 20)/2 + 10;
            _tf.y = -(_tf.textHeight + 20)/2 + 10;
			
            _bg = new BitmapData(465, 465, true, 0x00FFFFFF);
            _bgBmp = new Bitmap(_bg);
            addChild(_bgBmp);

            tonedown = new ColorTransform(1, 1, 1, 0.999);  
            rect = new Rectangle(0, 0, 465, 465);
            pt = new Point(0, 0);
			
            container = new Sprite();
            container.scaleX = container.scaleY = 6;
            container.x = 465 / 2;
            container.y = 465 / 2;
            container.addChild(_tf);

            drawBox.addChild(container);

            _bmd = new BitmapData(container.width, container.height);
			
            initSpeed(10);
			
            fl_disp = new DisplacementMapFilter(_bmd, pt, 2, 4, _scale, _scale);
            fl_disp.scaleX = fl_disp.scaleY = 50;
			
            fl_blur = new BlurFilter(2, 2, 1)
			
            addEventListener(Event.ENTER_FRAME, update);
        }
		
        private function update(e:Event):void{
            _bg.colorTransform(rect, tonedown); 
            _bg.applyFilter(_bg, rect, pt, fl_blur);
            _bg.draw(drawBox);
			
            for(var i:int = 0; i < _octave; i++) {
                _ofsAry[i].x += _spdAry[i].x;
                _ofsAry[i].y += _spdAry[i].y;
            }
			
            _bmd.perlinNoise(width, height, _octave, _rndSeed, false, true, 2 | 4, false, _ofsAry);
            fl_disp.mapBitmap = _bmd;
            container.filters = [fl_disp];
        }

		
        private function initSpeed(val:Number):void{
            _ofsAry = new Array();
            _spdAry = new Array();
            for (var i:int = 0; i < _octave; i++) {
                _ofsAry.push(new Point(0, 0));
                _spdAry.push(
                    new Point(
                        val * (Math.floor(Math.random() * 2) == 0 ? -1 : 1),
                        val * (Math.floor(Math.random() * 2) == 0 ? -1 : 1)
                    )
                );
            }
        }
    }
}