例子如下:
代码如下:package { import flash.display.Sprite; import flash.media.Sound; import flash.media.SoundMixer; import flash.utils.ByteArray; import flash.events.Event; import flash.net.URLRequest; public class wave extends Sprite { var sd:Sound = new Sound(); var ba:ByteArray = new ByteArray(); public function wave() { sd.load(new URLRequest("05.mp3")); sd.play(0,1000); for (var i:int=0; i <= 255; i++) { var _circle:Sprite = new Sprite(); _circle.graphics.beginFill(0xffffff*i); _circle.graphics.drawCircle(0,0,1); _circle.graphics.endFill(); _circle.x=72 + i; _circle.y=150; this.addChild(_circle); } addEventListener(Event.ENTER_FRAME,onEnterFrame); } private function onEnterFrame(event:Event):void { SoundMixer.computeSpectrum(ba,true,0); for (var i:int=0; i < 255; i++) { this.getChildAt(i).scaleY=3+ba.readFloat()*150; } } } }
回复Comments
{commenttime}{commentauthor}
{CommentUrl}
{commentcontent}