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

雲海

雲海
civet
dreamana.com
2009-04-08 12:11:14
/**
 * 雲海
 * civet
 * dreamana.com
 * 2009-04-08 12:11:14
 */
package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.BitmapDataChannel;
    import flash.display.GradientType;
    import flash.display.SpreadMethod;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.filters.DropShadowFilter;
    import flash.geom.ColorTransform;
    import flash.geom.Matrix;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.utils.Timer;
    
    [SWF(frameRate='24', backgroundColor='0x000000')]
    public class Sora extends Sprite {
        private var source:BitmapData;
        private var rect:Rectangle;
        private var seed:int;
        private var offset:Point;
        private var trans:ColorTransform;        

        public function Sora() {
            createSky(stage.stageWidth, stage.stageHeight);
            createCloud(stage.stageWidth, stage.stageHeight);
        }
        
        private function createSky(w:uint, h:uint):void {
            var bg:Sprite = new Sprite();
            var colors:Array = [0x09B6FF, 0xFFFFFF];
            var alphas:Array = [1, 1];
            var ratios:Array = [0x00, 0xFF];
            var mat:Matrix = new Matrix();
            mat.createGradientBox(w, h, Math.PI/2, 0, 0);
            bg.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, mat, SpreadMethod.PAD);
            bg.graphics.drawRect(0, 0, w, h);
            bg.graphics.endFill();
            addChild(bg);
        }    

        private function createCloud(w:uint, h:uint):void {            
            source = new BitmapData(w, h, true, 0);
            var bmp:Bitmap = new Bitmap(source);
            addChild(bmp);
            //bmp.filters = [new DropShadowFilter(4, 45, 0xb3b3b3)];
            
            rect = new Rectangle(0, 0, source.width, source.height);
            seed = Math.random()*100;
            offset = new Point();
            trans = new ColorTransform(1,1,1,2, 255,255,255, -200);
            
            render();
            
            var t:Timer = new Timer(500);
            t.addEventListener(TimerEvent.TIMER, render);
            t.start();
        }

        private function render(e:Event=null):void {
            offset.x += 8;
            source.perlinNoise(256, 100, 4, seed, false, true, BitmapDataChannel.ALPHA, false, [offset]);
            source.colorTransform(rect, trans);
        }
    }
}