模拟酷狗2008声音频谱。

时间:2021-07-26 00:52:49
示例:
   
代码:
<? xml version="1.0" encoding="utf-8" ?>
<!--  http://www.duzengqiang.com  -->
< mx:Application  xmlns:mx ="http://www.adobe.com/2006/mxml"
        layout
="vertical"
        verticalAlign
="top"
         backgroundColor
="0x57b3da"
         creationComplete
="init()" >
    
< mx:Script >
            
<![CDATA[
                
                import mx.graphics.ImageSnapshot;
                private function init():void{
                    var timer:Timer = new Timer(100);
                    
                    var j:Array=          [0,0,0,0,0,
                                        0,0,0,0,0,
                                        0,0,0,0,0,
                                        0,0,0,0,0];
                    var rectY:Array =  [0,0,0,0,0,
                                        0,0,0,0,0,
                                        0,0,0,0,0,
                                        0,0,0,0,0];
                                        
                    var g:Graphics = container.graphics;
                    timer.addEventListener(TimerEvent.TIMER, function(e:Event):void{                       
                        g.clear();
                        g.beginFill(0xffffff);
                       for(var i:int=0; i<20; i++){
                            var h:Number = 20*Math.random()
                            if(rectY[i] + j[i]*j[i]  > 20-h){
                                    j[i]= 0;
                                    rectY[i] = 20-h;
                            }else{                                
                                rectY[i] += j[i]*j[i];
                                j[i]++;
                            }
                            g.drawRect(4*i , rectY[i] - 2, 3, 1);
                            g.drawRect(4*i , 20- h, 3, h);
                         }
                    });
                    timer.start();
                }
            
]]>
    
</ mx:Script >
< mx:Canvas  id ="container"   width ="100%"  height ="100%" />
</ mx:Application >

来自:杜增强