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

soundtest7 - E.R.O

深夜に思いついたのでE.R.Oド直球でごめんなさい。
Get Adobe Flash player
by gaina 02 Jul 2010
/**
 * Copyright gaina ( http://wonderfl.net/user/gaina )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2VSs
 */

//深夜に思いついたのでE.R.Oド直球でごめんなさい。

package  
    {
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.media.SoundLoaderContext;
        import flash.media.SoundMixer;
        import flash.net.URLRequest;
        import flash.utils.ByteArray;        
        
        [SWF(width=465,height=465,backgroundColor=0xe8d3d1)]
        public class oppaiSpectrum extends Sprite
        
        {
            private var spL:Sprite;
            private var spR:Sprite;
            
            private var numL:Number;
            private var numR:Number;
            
            private var snd:Sound;
            
            function oppaiSpectrum() 
            {
                Wonderfl.capture_delay(8);
                
                var spOppai:Sprite = new Sprite();
                spOppai.graphics.lineStyle(2, 0xf6bfbc);
                spOppai.graphics.moveTo(30, 200);
                spOppai.graphics.curveTo(100, 400, stage.stageWidth / 2, 200);
                spOppai.graphics.curveTo(365, 400, 435, 200);
                addChild(spOppai);
                
                spL = new Sprite();
                spL.graphics.beginFill(0xe198b4);
                spL.graphics.drawCircle(0, 0, 50);
                spL.graphics.endFill();
                spL.x = 110; spL.y = 300;
                addChild(spL);
                
                spR = new Sprite();
                spR.graphics.beginFill(0xe198b4);
                spR.graphics.drawCircle(0, 0, 50);
                spR.graphics.endFill();
                spR.x = 355; spR.y = 300;
                addChild(spR);
                
                playSound("http://www.takasumi-nagai.com/soundfiles/sound001.mp3");
                addEventListener(Event.ENTER_FRAME, onEnterFrame);
            }
            
            private function playSound(sndUrl:String):void
            {
                snd = new Sound();
                var context:SoundLoaderContext = new SoundLoaderContext(10,true);
                var req:URLRequest = new URLRequest(sndUrl);
                snd.load(req, context);
                var sndChannel:SoundChannel=new SoundChannel();
                sndChannel = snd.play(0, 5);
                
            }
            
            private function onEnterFrame(event:Event):void {
                var bytes:ByteArray = new ByteArray();
                SoundMixer.computeSpectrum(bytes, false, 1);
                var i:uint, j:uint;
                for (i = 0; i < 2; i++)
                {
                    for (j = 0; j < 256; j++)
                    {
                        var rf:Number = bytes.readFloat();
                        if (i==0) {
                            spL.scaleX = spL.scaleY = rf ;
                        }else {
                            spR.scaleX = spR.scaleY = rf ;
                        }
                    }
                }
                
            }
        }
    }