Sound spectrum

by Girish
import flash.text.TextFormat;
♥0 | Line 57 | Modified 2011-04-20 17:39:58 | MIT License
play

ActionScript3 source code

/**
 * Copyright Girish ( http://wonderfl.net/user/Girish )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/hte4
 */

package {
    import flash.text.engine.TextLine;
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;
    import flash.events.*;
    import flash.utils.ByteArray;
    import flash.media.SoundMixer;
    
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.text.TextFormat;
    
    [SWF (width="500", height="500", backgroundColor="0x000000", framerate="30")]    
    public class soSp extends MovieClip {
        private var mySound:Sound;
        //private var myChannel:SoundChannel;
        private var sSpt:Sprite;
        private var spectrumInfo:ByteArray;
        public var tf:TextField;
        public var count:uint;
        
        public function soSp() {
            soundInit();
            sSpt = new Sprite();
            tf = new TextField();
            tf.name ="tf";
            tf.x = tf.y = 0;
            tf.width = 400;
            tf.height = 20;
            tf.textColor = 0xffffff;
            //tf.text = tfLable(count);
            addChild(tf);
            addChild(sSpt);
        }
        private function soundInit():void{
            var request:URLRequest=new URLRequest("http://sound23.mp3pk.com/indian/faltu/faltu02(www.songs.pk).mp3");
            mySound=new Sound(request);
            mySound.play(0,0);
            addEventListener(Event.ENTER_FRAME, sLoop);
        }

        private function sLoop (e:Event):void{
            //SoundMixer.computeSpectrum(spectrumInfo);
            //sSpt.removeChildAt(0);
            while(sSpt.numChildren>1){
                
            }

            var ntf:TextField = new TextField();
            ntf.x = 00;
            ntf.y = 10;
            ntf.height = 20;
            ntf.width = 400;
            ntf.text = new String(count++);//tfLable(count);
            ntf.textColor = 0xffffff;
            sSpt.addChild(ntf);
       }
       
       private function tfLable (c:uint):String {
           c++;
           var tStr:String = new String(c);
           return tStr;
       }
        
        
    }
}