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

砂嵐

////////////////////////////////////////////////////////////////////////////////
// 砂嵐
//
// BitmapDataでノイズ生成 (1)
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=477
// [AS3.0] Noiseクラスに挑戦!
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=1113
////////////////////////////////////////////////////////////////////////////////
Get Adobe Flash player
by ProjectNya 23 Jun 2011
    Embed
/**
 * Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/kSCo
 */

////////////////////////////////////////////////////////////////////////////////
// 砂嵐
//
// BitmapDataでノイズ生成 (1)
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=477
// [AS3.0] Noiseクラスに挑戦!
// http://www.project-nya.jp/modules/weblog/details.php?blog_id=1113
////////////////////////////////////////////////////////////////////////////////

package {

    import flash.display.Sprite;
    import flash.display.StageScaleMode;
     import flash.display.StageAlign;
    import flash.events.Event;
    import flash.geom.Rectangle;
    import flash.display.Bitmap;
    import flash.display.Shape;
    import flash.filters.DropShadowFilter;

    [SWF(backgroundColor="#000000", width="465", height="465", frameRate="30")]

    public class Main extends Sprite {
        private var noise:Noise;

        public function Main() {
            //Wonderfl.capture_delay(1);
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            init();
        }

        private function init():void {
            graphics.beginFill(0x000000);
            graphics.drawRect(0, 0, 465, 465);
            graphics.endFill();
            //
            var rect:Rectangle = new Rectangle(0, 0, 200, 160);
            //ノイズ生成
            noise = new Noise(rect);
            //
            draw();
            //
            addEventListener(Event.ENTER_FRAME, update, false, 0, true);
        }
        private function update(evt:Event):void {
            //ノイズ生成
            noise.create(uint(Math.random()*1000));
        }
        private function draw():void {
            var base:Shape = new Shape();
            addChild(base);
            base.graphics.beginFill(0x333333);
            base.graphics.drawRoundRect(-110, -90, 220, 180, 30);
            base.graphics.endFill();
            base.x = 232;
            base.y = 232;
            //
            var overlay:Shape = new Shape();
            addChild(overlay);
            overlay.graphics.beginFill(0x000000);
            overlay.graphics.drawRoundRect(-100, -80, 200, 160, 20);
            overlay.graphics.endFill();
            overlay.x = 232;
            overlay.y = 232;
            //
            var bitmap:Bitmap = new Bitmap(noise);
            addChild(bitmap);
            bitmap.x = 132;
            bitmap.y = 152;
            bitmap.mask = overlay;
            //
            var shade:Shape = new Shape();
            addChild(shade);
            shade.graphics.beginFill(0x000000);
            shade.graphics.drawRoundRect(-100, -80, 200, 160, 20);
            shade.graphics.endFill();
            shade.x = 232;
            shade.y = 232;
            shade.filters = [new DropShadowFilter(0, 90, 0x000000, 0.3, 8, 8, 2, 3, true, true, true)];
        }
        
    }

}


//////////////////////////////////////////////////
// Noiseクラス
//////////////////////////////////////////////////

import flash.display.BitmapData;
import flash.geom.Rectangle;

class Noise extends BitmapData {
    private var seed:uint;
    private static var low:uint = 0;
    private static var high:uint = 255;
    private var channel:uint = 0;
    private var grayScale:Boolean = true;

    public function Noise(rect:Rectangle, g:Boolean = true, c:uint = 0, s:uint = 1) {
        super(rect.width, rect.height, false, 0xFF000000);
        grayScale = g;
        channel = c;
        if (grayScale) channel = 0;
        create(s);
    }

    public function create(s:uint):void {
        seed = s;
        if (seed == 0) seed = Math.floor(Math.random()*1000);
        lock();
        noise(seed, low, high, channel, grayScale);
        draw(this);
        unlock();
    }

}