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 syunsuke 31 Aug 2010
// write as3 code here..
package 
{
    import flash.display.*;
    import flash.geom.*;
    import flash.events.*;
    import flash.utils.*;
    import flash.ui.*;
    import flash.filters.*;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.media.SoundLoaderContext;
    import flash.media.SoundMixer;
    import flash.utils.ByteArray;
    import flash.net.URLRequest;
    import flash.system.Security;
    import caurina.transitions.Tweener;
    import net.hires.debug.Stats;
    
    [SWF(width="400", height="400", backgroundColor="0x000000", frameRate="30")]
    public class Meta extends Sprite 
    {
        //メンバ変数 
        private var Ball_Numbers:int = 1;
        
        private var canvas:DisplayObjectContainer;
        private var canvas_sprite:Sprite;
        private var screen:Bitmap;
        private var contener:BitmapData;
        private var screenRect:Rectangle;
        private var origin:Point;
        private var stage_w:int = stage.stageWidth;
        private var stage_h:int = stage.stageHeight;
        private var stage_w_min:int = 0;
        private var stage_h_min:int = 0;
        private var bitmap_w:int = 200;
        private var bitmap_h:int = 200;
        private var blurFilter:BlurFilter;
        private var collerArray:Array = [0x904981,0x990000,0xE1B64E,0x65811B,0xA95322,0x006699];
        
        private var sound:Sound;
        private var channel:SoundChannel;
        private static var soundPath:String = "http://www.takasumi-nagai.com/soundfiles/sound001.mp3";
        private var byteArray:ByteArray;
        private static var channels:uint = 256;
        private static var factors:uint = 42;
        private var count:uint = 0;
        
        //コンストラクタ
        public function Meta():void
        {
            trace("コンストラクタ : constract_name")
            addEventListener( Event.ADDED_TO_STAGE, init );
        }
        
                //初期化
        private function init(e:Event):void
        {
            trace("function : init")
            removeEventListener( Event.ADDED_TO_STAGE, init ); 
            
            stage.frameRate = 30;
            stage.scaleMode = StageScaleMode.NO_SCALE
            stage.align = StageAlign.TOP_LEFT;
            
            blurFilter = new BlurFilter(64,64 , 3);
            
            canvas_sprite = new Sprite();
            canvas_sprite.x = stage_w;
            canvas_sprite.y = stage_h;
            
            canvas = canvas_sprite;
            screen = new Bitmap();
            screen.bitmapData = new BitmapData(bitmap_w , bitmap_h , true );
            screen.x = 0;
            screen.y = 0;
            
            origin = new Point(0, 0);
            screenRect = new Rectangle(0, 0, bitmap_w, bitmap_h);
            
            addChild(screen);
            addChild(new Stats());
            /*
            initBalls(0x904981);
            initBalls(0x990000);
            initBalls(0xE1B64E);
            initBalls(0x65811B);
            initBalls(0xA95322);
            initBalls(0x006699);
            */
            sound = new Sound();
            sound.addEventListener(Event.COMPLETE, complete, false, 0, true);
            sound.load(new URLRequest(soundPath), new SoundLoaderContext(10, true));
            byteArray = new ByteArray();

            addEventListener(Event.ENTER_FRAME , EnterFrameHandler);
            
        }
        
        
        private function complete(evt:Event):void {
            evt.target.removeEventListener(Event.COMPLETE, complete);
            start();
        }
        private function start():void {
            channel = sound.play(0, 5);
            addEventListener(Event.ENTER_FRAME, update, false, 0, true);
        }
        private function update(evt:Event):void {
            count ++;
            if (count%8 == 0) {
                SoundMixer.computeSpectrum(byteArray, true, factors);
                for (var n:uint = 0; n < channels; n++) {
                    var px:Number = n + 120;
                    var pw:Number = byteArray.readFloat();
                    if (n%factors == 0 && pw > 0.2) {
                        initBalls(0x006699);
                    }
                }
            }
        }
        
                //ボールの生成
        private function initBalls(color:uint):void {
            trace("function : initBalls")
            //shuffle();
            for ( var i:uint = 0; i < Ball_Numbers; i++ ) {
                var ball:Ball = new Ball(Math.random() * 6 + 30 , color );
                ball.alpha = 0;
                ball.x = Math.random() * stage_w;
                ball.y = Math.random() * stage_h;
                ball.vx = Math.random() * 4-2;
                ball.vy = Math.random() * 4-2;
                Tweener.addTween(ball, { alpha:1 , time:0.4 , delay:0.0, transition:"easeInOutCubic" } );
                Tweener.addTween(ball, { alpha:0 , time:0.4 , delay:1.4, transition:"easeInOutCubic" ,onComplete:onEnd} );
                canvas.addChild(ball);
            }
        }
        
        private function onEnd():void
        {
            var b:Ball = canvas.getChildAt(0) as Ball;
            canvas.removeChild(b);
        }

        
        //ボールの動き
        private function EnterFrameHandler(e:Event):void 
        {
            for ( var i:uint = 0; i < canvas.numChildren ; i++ ) {
                var b:Ball = canvas.getChildAt(i) as Ball;
                //b.alpha = 0.2;
                b.x += b.vx;
                b.y += b.vy;
                if ( b.x + b.width > bitmap_w ) {
                    b.vx *= -1;
                    b.x = bitmap_w - b.width;
                }
                if ( b.x < stage_w_min ) {
                    b.vx *= -1;
                    b.x = stage_w_min;
                }
                if ( b.y + b.height > bitmap_h ) {
                    b.vy *= -1;
                    b.y = bitmap_h  - b.height;
                }
                if ( b.y < stage_h_min ) {
                    b.vy *= -1;
                    b.y = stage_h_min;
                }
            }
            
            render();
        }
        
        //表示設定
        private function render():void 
        {
                screen.bitmapData.lock();
                screen.bitmapData.fillRect(screenRect, 0x000000);
                screen.bitmapData.draw(canvas_sprite);
                screen.bitmapData.applyFilter(screen.bitmapData, screenRect, origin, blurFilter);
                screen.bitmapData.unlock();
                                screen.scaleX = 2;
                                screen.scaleY = 2;
        }
        
        public static function shuffle(arr:Array):Array
        {
            var l:int = arr.length;
            var newArr:Array = arr;
            while(l){
                var m:Number = Math.floor(Math.random()*l);
                var na:Array = newArr[--l];
                newArr = newArr[m];
                newArr[m] = na;
            }
            return newArr;
        }
        
    }
}
import flash.display.Sprite;
import flash.events.MouseEvent;

    class Ball extends Sprite 
    {
        //メンバ変数 
        public var radius:Number;
        public var color:uint;
        public var vx:Number = 0;
        public var vy:Number = 0;
        
        
        //コンストラクタ
        public function Ball(radius:Number = 40 , color:uint = 0xff0000):void
        {
            trace("コンストラクタ : Ball")
            this.radius = radius;
            this.color = color;
            init();
        }
        private function init():void
        {
            trace("function : init")
            graphics.beginFill(color);
            graphics.drawCircle(0 , 0 , radius);
            graphics.endFill();
        }
        
    }