flash on 2011-5-3
To Do:load music
package {
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.events.Event;
import flash.display.Shape;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.media.SoundMixer;
import flash.media.Sound;
import flash.utils.ByteArray;
[SWF(width="512",height="512",frameRate="60",backgroundColor="0x000000")]
public class FlashTest extends Sprite {
private var bmd:BitmapData;
private var bmp:Bitmap;
private var bf:BlurFilter;
private var ds:Shape;
private var arr:ByteArray;
public function FlashTest() {
bmd=new BitmapData(512,512,true,0xff000000);
bmp=new Bitmap(bmd);
addChild(bmp);
ds=new Shape();
bf=new BlurFilter(4,4,2);
arr=new ByteArray();
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
private function onEnterFrame(e:Event):void{
SoundMixer.computeSpectrum(arr,false,0);
ds.graphics.clear();
ds.graphics.lineStyle(1,0xe0c0f0,1);
ds.graphics.moveTo(0,256);
for(var i:uint=0;i<512;i++){
ds.graphics.lineTo(i,arr.readFloat()*128+256);
}
bmd.draw(ds);
bmd.applyFilter(bmd,bmd.rect,new Point(),bf);
}
}
}