private var _channel:SoundChannel; private var _graph:Sprite;
public function Main() { Security.loadPolicyFile("http://navioo.com/crossdomain.xml"); var sound:Sound = new Sound(); sound.load(new URLRequest("http://navioo.com/Demo.mp3"), new SoundLoaderContext(1000, true)); _channel = sound.play(); _graph = new Sprite(); _graph.y = 200; addChild(_graph); addEventListener(Event.ENTER_FRAME, enterFrameHandler); }
private function enterFrameHandler(event:Event):void { var bytes:ByteArray = new ByteArray(); SoundMixer.computeSpectrum(bytes); _graph.graphics.clear(); _graph.graphics.lineStyle(0, 0, 1); var plotX:Number = 0; for(var i:Number = 0; i < 256; i++) { _graph.graphics.lineTo(plotX, bytes.readFloat() * stage.stageHeight / 2); plotX += stage.stageWidth / 256; } } } }
Related Scripts with Example Source Code in same category :