小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

模拟酷狗2008声音频谱。

示例:
   
代码:
<?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>

来自:杜增强

posted on 2008-06-17 15:43  『小小菜鸟』  阅读(733)  评论(0编辑  收藏  举报